Async logging throwing a NullReferenceException

前端 未结 3 350
既然无缘
既然无缘 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 06:56

    Dataflow only works on .NET 4.5. The fact that you're running it on .NET 4.0 is unsupported and is likely why you're seeing spurious exceptions.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-02 07:11

    I had this problem with .net4.5 when my web service was invoking another WCF service in an async manner. I simply appended a short timed Wait() as I didn't care about the response (telemetry event).

    public static void Event(string key, string message) {
        Telemetry.Event(key, message).Wait(100);
    }
    
    0 讨论(0)
提交回复
热议问题