ToolTip上的AccessViolationException导致COMCTL32.dll - .NET 4.0出现故障

问题描述 投票:14回答:3

我们的Windows窗体应用程序遇到问题,因为堆栈跟踪指示的类型为AccessViolationException的未处理异常发生在ToolTip控件中。

错误发生在应用程序的不同时间,我们目前无法可靠地重现它。在这个阶段,它仅在Windows 7的生产中发生,并且仅针对某些用户,而不是其他用户 - 即使在以类似方式使用该应用程序的用户中也是如此。它看起来与机器有关,所以我们做了一些事情,比如确保图形驱动程序是最新的。

在事件日志中,始终记录了2个不同的错误,其中一个与我们的应用程序有关:

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[])

一个与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

第一个堆栈跟踪根据工作流中错误发生的位置而变化,但是,堆栈中的前9项始终相同,差异通常是出现在Main()方法和RunMessageLoop方法之间的showDialog调用。例如。:

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[])

----更新----

我有一个请求要包含Main的一些代码,我不想包含所有代码,但提取的是:

 <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

一些额外的说明:

有谁知道是什么原因引起的?

谢谢,

winforms windows-7 .net-4.0 tooltip
3个回答
22
投票

根据MS,在某些情况下DataGrid控件存在已知问题,避免此问题的方法是禁用DataGrid控件的工具提示。

我们将在接下来的几天内实施变更并将其推广到试点小组,我将在大约一周后回复成功/失败(除非当然在此之前发生失败)。

根据MS设置的属性是DataGridView.ShowCellToolTips = false;

这解决了我们的应用程序的问题。

要重现此问题,我们需要执行以下操作:

  • 将鼠标悬停在我们知道会显示工具提示的DataGridView中的单元格上
  • 在显示工具提示之前,将Alt选项卡移动到另一个应用程序(将显示在应用程序顶部)
  • 不要移动鼠标
  • Alt标签返回我们的应用程序
  • 我们的应用程序崩溃了。

10
投票

似乎在DataGridView.ShowCellToolTips = false上设置Form.Deactivate可以防止崩溃。它可以在Form.Activate上重置为true。

工具提示仍然显示在新聚焦的窗口上方 - 但我想这比撞击更好。

甚至更好:

仅当未启用视觉样式时才会出现此问题。

在任何形式实例化之前在Application.EnableVisualStyles()中添加main()解决了这个问题。


0
投票

更多细节https://github.com/Microsoft/dotnet/issues/402

6年后,遗憾的是解决方案仍然是“使用comctl v6”

© www.soinside.com 2019 - 2024. All rights reserved.