小编Alb*_*ert的帖子

System.Runtime.CompilerServices.AsyncServices中的NullReferenceException.<ThrowAsync> b__1()

我有一个.NET 4.0 Web项目,并使用Microsoft.Bcl.Async来支持异步/等待功能.我注意到在生产环境中,IIS工作进程由于引发了NullReferenceException而不断崩溃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()
Run Code Online (Sandbox Code Playgroud)

我的代码中没有明显的位置可能会抛出此异常并在没有任何输出的情况下处理崩溃.

我该如何调试?有没有办法找到这个例外的来源?

c# .net-4.0 nullreferenceexception async-await c#-4.0

6
推荐指数
1
解决办法
1575
查看次数