Some of the users of my application experience strange crashes from different exceptions in System.Runtime.CompilerServices.AsyncServices
There is none of my code in the stack trace and I don't have a clue where to search for a cause or how to add additional logging to find the reason of the crash. Googling did not help.
Examples of exceptions are:
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()
Additional information: I am targeting NET 4.0 and using Microsoft.Bcl.Async. First of the exceptions described above happened on a machine with Win 7 / NET 4.0
Update: I'll try to clarify the question.
It seems that these stack traces can appear if some exception happens in async method. Is there a way to find the place where original exception happened? Because it is very hard to debug such issues without knowing anything but the exception message.
Task
? anyBeginInvoke
? anyThreadPool
? You mention Bcl.Async - have you checked whether you are catching all worker exceptions? – Marc Gravell♦AsyncServices.<ThrowAsync>b__0()
. Do make sure that your logging code isn't borken. – Hans Passant