首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调试winform崩溃- C# [ADPlus + Windbg]

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

Stack Overflow用户
提问于 2011-02-15 16:37:01
回答 1查看 1.7K关注 0票数 2
代码语言:javascript
复制
 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调试器,并运行了7-10次测试,并且成功地捕获了这个堆栈跟踪。请注意,所有这些代码都不是我的代码,所以在windows级别上发生了一些可怕的事情。顺便说一句,我们使用PInvoke打开/关闭诸如iexplore、记事本等窗口。

经过一些-- 搜索 --并根据来自微软的那个家伙的建议,我尝试让ADPlus去分析内存转储& Windbg,但是我从windbg获得的信息比异常本身更加神秘。

代码语言:javascript
复制
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=????????

可以有一些专家能够理解这些信息,我不能。

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-02-15 17:35:50

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

不确定是否需要以下步骤,但我只是在visual studio的即时窗口中执行了.load SOS.dll

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

谢谢每一个发了回复或评论的人。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5006520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档