我的应用程序的一些用户遇到了 System.Runtime.CompilerServices.AsyncServices 中不同异常导致的奇怪崩溃
堆栈跟踪中没有我的代码,我不知道在哪里搜索原因或如何添加额外的日志记录来查找崩溃原因。 谷歌搜索没有帮助。
异常(exception)的例子是:
String reference not set to an instance of a String. Parameter name: s Void System.Runtime.CompilerServices.AsyncServices.b__0(System.Object) System.Object System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) System.Object MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) Void System.Windows.Threading.DispatcherOperation.InvokeImpl() Void System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) Void System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) Void System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) Void System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) Void System.Windows.Threading.DispatcherOperation.Invoke() Void System.Windows.Threading.Dispatcher.ProcessQueue() IntPtr System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) IntPtr MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) System.Object MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) System.Object System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) System.Object MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) System.Object System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) IntPtr MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) IntPtr MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) Void System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) Void System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) Void System.Windows.Threading.Dispatcher.Run() System.Object System.Windows.Application.RunDispatcher(System.Object) Int32 System.Windows.Application.RunInternal(System.Windows.Window) Int32 System.Windows.Application.Run(System.Windows.Window) Int32 System.Windows.Application.Run() App.g.cs - Void MyProject.App.Main()
Object reference not set to an instance of an object. Void System.Runtime.CompilerServices.AsyncServices.b__0(System.Object) System.Object System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) System.Object MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) Void System.Windows.Threading.DispatcherOperation.InvokeImpl() Void System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) Void System.Threading.ExecutionContext.runTryCode(System.Object) Void System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) Void System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) Void System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) Void System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) System.Object System.Windows.Threading.DispatcherOperation.Invoke() Void System.Windows.Threading.Dispatcher.ProcessQueue() IntPtr System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) IntPtr MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) System.Object MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) System.Object System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) System.Object MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) System.Object System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) IntPtr MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) IntPtr MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) Void System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) Void System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) System.Object System.Windows.Application.RunDispatcher(System.Object) Int32 System.Windows.Application.RunInternal(System.Windows.Window) Int32 System.Windows.Application.Run(System.Windows.Window) Int32 System.Windows.Application.Run() App.g.cs - Void MyProject.App.Main()
附加信息: 我的目标是 NET 4.0 并使用 Microsoft.Bcl.Async。 上述第一个异常发生在装有 Win 7/NET 4.0 的机器上
更新:我会尝试澄清这个问题。
似乎如果在异步方法中发生某些异常,就会出现这些堆栈跟踪。 有没有办法找到原始异常发生的地方?因为在除了异常消息之外什么都不知道的情况下很难调试此类问题。
请您参考如下方法:
由于似乎没有人知道更好的解决方案,所以我将发布我使用的解决方案。
我发现导致这些崩溃之一的原始异常总是先触发 FirstChanceException 事件。
为了了解异常的原因,我做了以下操作:
- 记录所有 FirstChanceException 事件和相应异常的详细信息。
- 在崩溃报告中包含一些最后记录的 FirstChanceExceptions 数据。
