我有一个 .NET 4.0 Web 项目并使用 Microsoft.Bcl.Async 来支持 async/await 功能。我注意到在生产环境中 IIS 工作进程由于在System.Runtime.CompilerServices.AsyncServices.<ThrowAsync>b__1()
. 似乎异常是在我的代码中的其他地方抛出的,并在AsyncServices.ThrowAsync()
方法中重新抛出。不幸的是,任何异常详细信息(包括原始堆栈跟踪)都丢失了,所以我不知道异常最初是在哪里引发的。此外,我尝试使用 AppDomain.CurrentDomain.UnhandledException 和 TaskScheduler.UnobservedTaskException 事件来捕获此异常,但这些事件从未被触发。
我有所有错误详细信息(来自 EventLog):
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
StackTrace: at System.Runtime.CompilerServices.AsyncServices.<ThrowAsync>b__1(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
我的代码中没有明显的地方可能会引发此异常并在没有任何输出的情况下处理崩溃。
我该如何调试?有没有办法找到这个异常的来源?