在我的WinForms應用程序我得到下面的異常隨機場合:C#的WinForms:調試策略,找到原因System.AccessViolationException
Application: My.Shell.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.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.Run(System.Windows.Forms.Form)
at Microsoft.Practices.CompositeUI.WinForms.FormShellApplication`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Start()
at Microsoft.Practices.CompositeUI.CabApplication`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Run()
at My.Shell.ModuleLoader.Main()
堆棧跟蹤是從Windows事件查看器。 (該unandeled異常處理程序沒有得到它。)
我看了很多文章對此的SO:
- C# WinForms exception: A first chance exception of type 'System.AccessViolationException'
- finding the cause of System.AccessViolationException
- AccessViolationException from System.Windows.Forms, using WinFormsHost in WPF
- AccessViolationException from a combo: Attempted to read or write protected memory
它事實證明,我的應用程序somwhere訪問通過本地方法處置或損壞的內存。我現在的問題是如何使用我使用taskmanager製作的crashdump來查找該位置。 是否有其他策略可以找到原因?
您是否在深度標記了異常 - 促銷,您需要? – icbytes 2015-02-06 13:49:34
我該怎麼做?從未聽說過「促進例外」。你能解釋一下這是什麼意思嗎?謝謝。 – schoetbi 2015-02-06 13:52:39
@schoetbi你在代碼庫的任何地方使用COM Interop嗎? – toadflakz 2015-02-06 13:56:06