We are having an issue with our Windows forms application where it is terminating due to an unhandled exception of type AccessViolationException that the stack trace is indicating occurs within the ToolTip control.
The error occurs at different times in the application, and we are currently not able to reliably reproduce it. At this stage it is occurring only in production on Windows 7 and only for some users, but not others – even amongst users that use the application in a similar way. It appears to be machine related and so we have done things like ensure the graphics driver is up to date.
In the event log, there are always 2 different errors logged, one relating to our application:
Application: <Application>.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.ToolTip.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.ToolTip+ToolTipNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
at <Company>.Windows.Forms.<Application>.Startup.Main(System.String[])
And one relating to comctl32.dll:
Faulting application name: <Application>.exe, version: 7.13.0.2086, time stamp: 0x4ec5e710
Faulting module name: comctl32.dll, version: 5.82.7601.17514, time stamp: 0x4ce7b82c
Exception code: 0xc0000005
Fault offset: 0x00043286
Faulting process id: 0xcdc
Faulting application start time: 0x01cca96312446309
Faulting application path: C:\Program Files\<Company>\Client\<Application>.exe
Faulting module path: C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll
Report Id: b425143c-1575-11e1-bccf-6c626d955bf1
The first stack trace changes depending on where in the workflow the error occurs, however, the top 9 items on the stack are always the same, the difference is usually a showDialog call that appears in between the Main() method and the RunMessageLoop method. E.g.:
Application: <Application>.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.ToolTip.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.ToolTip+ToolTipNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form)
at System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window)
at System.Windows.Forms.Form.ShowDialog()
at <Company>.Windows.Forms.<Application>.ApplicationForm.<EventSubscribingMethod>(System.Object, System.EventArgs)
at <Company>.<Application>.<Class1>.RaiseShowResultDialogNowEvent()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Form.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
at <Company>.Windows.Forms.<Application>.Portal.Startup.Main(System.String[])
---- Update ----
I have had a request to include some of the code from Main, I don't want to include all code, but an extract is:
<System.STAThread()> _
Public Shared Function Main(ByVal args() As String) As Integer
-- Perform startup validation, setup logging framework, etc
...
Dim appLife as new ApplicationContext(myStartupForm)
Application.Run(appLife)
Return 0
End Function
Some additional notes:
- We are using the UI Process Application Block from MS Patterns and Practices
- We do override WndProc in a couple of controls, including CheckBoxComboBox from code project at http://www.codeproject.com/KB/combobox/extending_combobox.aspx
Does anyone know what could be causing this?
Thanks,