调试winform崩溃-C#[ADPlus+;Windbg]

调试winform崩溃-C#[ADPlus+;Windbg],c#,winforms,pinvoke,windbg,adplus,C#,Winforms,Pinvoke,Windbg,Adplus,这是一个很难重现的例外,是非常不可预测的。我连接了VisualStudio调试器并运行了7-10次测试,并且能够成功捕获此堆栈跟踪。请注意,这些都不是我的代码,因此在windows级别发生了一些可怕的事情。顺便说一句,我们使用PInvoke打开/关闭窗口,如iexplore、记事本等 经过一段时间之后——根据微软那个家伙的建议,我试着用ADPlus让内存转储&Windbg进行分析,但我从Windbg获得的信息比异常本身更加神秘 System.AccessViolationException

这是一个很难重现的例外,是非常不可预测的。我连接了VisualStudio调试器并运行了7-10次测试,并且能够成功捕获此堆栈跟踪。请注意,这些都不是我的代码,因此在windows级别发生了一些可怕的事情。顺便说一句,我们使用PInvoke打开/关闭窗口,如iexplore、记事本等

经过一段时间之后——根据微软那个家伙的建议,我试着用ADPlus让内存转储&Windbg进行分析,但我从Windbg获得的信息比异常本身更加神秘


 System.AccessViolationException was unhandled
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=System.Windows.Forms
  StackTrace:
       at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at ABC.Program.Main() in C:\Documents and Settings\...\Program.cs:line 17
  InnerException: 
可能有一些专家能够理解这些信息,但我不能

那么,你们怎么分析这些问题呢?类似于.Net的“JVM堆转储分析器”吗?


环境:Windows XP SP3[完全访问,管理员]

在Visual Studio中,转到项目属性并启用“非托管代码解包”,然后启动调试器

[不确定是否需要下面的步骤,但我只是做了] 在visual studio的即时窗口中执行.加载SOS.dll

我找到了问题的根本原因:对“ABC.Form1+SendMessageDelegate::Invoke”类型的垃圾收集委托进行了回调。这可能会导致应用程序崩溃、损坏和数据丢失。当将委托传递给非托管代码时,托管应用程序必须使委托保持活动状态,直到保证永远不会调用委托为止


感谢所有发表回复或评论的人。

您的环境和操作系统用户帐户访问权限是什么?运行WinDbg命令时是否加载了符号和SOS.dll?如果是这样,您可以尝试
!分析-v
了解更多信息-如果没有,我建议您从这里开始@Dan-我从下载了符号,命令“!analyze-v”显示了我已经拥有的堆栈跟踪(+一些详细信息)(NTSTATUS)0xc0000005-位于“0x%08lx”的指令引用了位于“0x%08lx”的内存。内存不能是“%s”)。。让我搜索SOS.dll并使用它

This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(904.1cf4): Access violation - code c0000005 (first/second chance not available)
eax=003c4d10 ebx=00000000 ecx=00000000 edx=00000000 esi=003c4d2a edi=0012f1a0
eip=003c4b64 esp=0012f11c ebp=0012f138 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
003c4b64 8b410c          mov     eax,dword ptr [ecx+0Ch] ds:0023:0000000c=????????
0:000> .ecxr
eax=003c4d10 ebx=00000000 ecx=00000000 edx=00000000 esi=003c4d2a edi=0012f1a0
eip=003c4b64 esp=0012f11c ebp=0012f138 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
003c4b64 8b410c          mov     eax,dword ptr [ecx+0Ch] ds:0023:0000000c=????????