Async logging throwing a NullReferenceException

前端 未结 3 369
既然无缘
既然无缘 2021-01-02 06:35

I am trying to asynchronously log some information to SQL Server inside of an MVC 4 controller action targeting .NET 4.0 using the AsyncTargetingPack. I would jump straight

3条回答
  •  暖寄归人
    2021-01-02 07:07

    I was just having a very similar issue (NullReference from AssociateWithCurrentThread when using a logging task).

    The issue I was having was that the original action did not await the completion of the logging task, so when the log finishes and tries to rejoin the original thread a nullReference is thrown because the original thread has terminated.

    This was solved for me by making sure that the request controller awaited the logging function.

提交回复
热议问题