2011-12-01 55 views
14

我們的Windows窗體應用程序出現問題,由於堆棧跟蹤指示的類型爲AccessViolationException的未處理異常在ToolTip控件內發生,所以它正在終止。工具提示上的AccessViolationException出現COMCTL32.dll - .NET 4.0錯誤

錯誤發生在應用程序的不同時間,我們目前無法可靠地重現它。 在此階段,它僅在Windows 7的生產環境中出現,並且僅針對某些用戶,而不是其他用戶,即使在以類似方式使用該應用程序的用戶中也是如此。 它似乎與機器相關,所以我們做了一些事情,例如確保圖形驅動程序是最新的。

在事件日誌中,總有一些記錄,一個與我們的應用2個不同的錯誤:與COMCTL32.DLL

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

而且一個:

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

---- ----更新

我有一個請求,包括一些從主要的代碼,我不希望包括所有代碼,而是一種提取物:

<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 

一些其他注意事項:

有誰知道什麼可能會造成這個?

感謝,

+0

顯示在'主要的代碼()'請。它看起來像你沒有調用'Application.Run'。 – leppie

+0

感謝您的額外信息。 '0xc0000005'是一個本地'NullReferenceException'。正如你所說的,你正在重載'WndProc',我可能會尋找任何空指針。 – leppie

回答

21

根據MS,有一個已知的問題,在某些情況下,DataGrid控件,以避免此問題的方法是禁用的工具提示爲您的DataGrid控件。

我們將在接下來的幾天內實施變更並將其發佈給試點小組,我將在大約一週後回覆成功/失敗(除非在此之前發生失敗)。

根據MS設置的屬性是DataGridView.ShowCellToolTips = false;

這個固定的問題,我們的應用程序。

要重現該問題,我們需要做到以下幾點:

  • 將鼠標懸停在我們的DataGridView單元格,我們知道會顯示一個提示
  • Alt鍵選項卡到另一個應用程序(將顯示你的應用程序的頂部)之前的提示顯示
  • 不要移動鼠標
  • Alt鍵標籤返回到程序
  • 我們的應用程序崩潰。
+0

哇!感謝您的回答,我終於能夠複製我的問題http://stackoverflow.com/q/7458915/68936!它吸取必須禁用所有datagridview的工具提示,但比我想的訪問衝突更好。你會碰巧有任何參考網址,或者「根據MS」是否意味着你通過與他們的私人對話獲得了信息?再次感謝您發佈您的答案。 – Jimmy

+1

嗨吉米,我通過付費支持得到了答案。沒有官方的KB,他們可以指出我不幸的。我很高興這幫助你,雖然:-) – Sean

+0

我欠你一頓午餐..非常感謝這個偉大的答案。我花了2個星期才發現這還沒有出現,但今天因爲你的禮貌......我可以找到一切。你是怎麼知道的? – Dhananjay

10

看起來,設置DataGridView.ShowCellToolTips = falseForm.Deactivate可以防止崩潰。可以在Form.Activate上重置爲true。

然而,工具提示仍然顯示在新聚焦的窗口上方,但是我認爲那會更好,然後崩潰。

甚至更​​好:

只有當未啓用視覺樣式出現問題。

在任何形式實例化之前,在的main()中添加Application.EnableVisualStyles()解決了問題。

+0

確認設置Application.EnableVisualStyles()解決了問題 – Jimmy