gpt4 book ai didi

winforms - 工具提示上的 AccessViolationException 导致 COMCTL32.dll - .NET 4.0

转载 作者:行者123 更新时间:2023-12-03 21:15:06 27 4
gpt4 key购买 nike

我们的 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

一些补充说明:
  • 我们正在使用 MS Patterns and Practices 中的 UI Process Application Block
  • 我们确实在几个控件中覆盖了 WndProc,包括来自 http://www.codeproject.com/KB/combobox/extending_combobox.aspx 的代码项目中的 CheckBoxComboBox。

  • 有谁知道是什么原因造成的?

    谢谢,

    最佳答案

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

    我们将在接下来的几天内实现更改并将其推广到试点小组,我将在大约一周内发布成功/失败的结果(当然,除非在那之前发生失败)。

    根据 MS 设置的属性是 DataGridView.ShowCellToolTips = false;
    这解决了我们应用程序的问题。

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

  • 将鼠标悬停在 DataGridView 中我们知道会显示工具提示的单元格上
  • 在显示工具提示之前,将 Alt 选项卡切换到另一个应用程序(将显示在您的应用程序顶部)
  • 不要移动鼠标
  • Alt 选项卡回到我们的应用程序
  • 我们的应用程序崩溃了。
  • 关于winforms - 工具提示上的 AccessViolationException 导致 COMCTL32.dll - .NET 4.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8335983/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com