2011-02-15 100 views
2

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: 

这很难重现异常,是非常不可预知的。我附加了我的visual studio调试器并运行测试7-10次,并能够成功捕获此堆栈跟踪。请注意,这些都不是我的代码,所以在windows级别发生一些令人发指的事情。顺便说一句,我们使用的PInvoke打开/关闭的窗户像IEXPLORE,记事本等调试winform崩溃 - C#[ADPlus + Windbg]

经过一番 - search - 并根据建议被那个家伙从微软我试图ADPlus的获得内存转储& WinDBG的分析得到,但我从windbg得到的信息比例外本身更加神秘。


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=???????? 

可以有一些专家,可以使这些信息SENCE,我不能。

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

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

+0

什么是您的环境和操作系统用户帐户访问? – 2011-02-15 16:40:10

+0

运行WinDbg命令时是否加载了符号和SOS.dll?如果是这样,你可以试试`!analyze -v`获取更多信息 - 如果没有,那么我建议你从那里开始! – 2011-02-15 16:43:19

回答

2

在Visual Studio中,转到项目属性,使 “非托管代码degubbing”,然后启动调试器。

[不知道下面的步骤是必需的,但我只是做了它] 在即时窗口执行的Visual Studio .load SOS.dll

我能找到问题的根本原因:一回调是在'ABC.Form1 + SendMessageDelegate :: Invoke'类型的垃圾收集委托上进行的。这可能会导致应用程序崩溃,损坏和数据丢失。在将代理传递给非托管代码时,它们必须由托管应用程序保持活动状态,直到确保它们永远不会被调用。

感谢大家谁发布了回复或评论。