简体   繁体   English

如何为.NET提供良好的故障转储?

[英]How do I take a good crash dump for .NET?

I have captured a crash dump of my 32 bit .NET application running on a 64 bit Windows operating system. 我捕获了在64位Windows操作系统上运行的32位.NET应用程序的故障转储。 During the analysis somebody found out that I have a 64 bit dump and told me that it is not possible to analyze this dump due to wrong bitness. 在分析过程中,有人发现我有一个64位转储并告诉我由于错误的位数而无法分析这个转储。

When using Windows Task Manager to create the dump, I was not aware that I was doing something wrong. 使用Windows任务管理器创建转储时,我不知道我做错了什么。 This always worked for 32 bit operating systems. 这始终适用于32位操作系统。

How can I take a good dump for .NET, especially with the correct bitness? 我怎样才能为.NET提供良好的转储,尤其是正确的位数?

Why is bitness relevant here? 为什么在这里有点相关?

The bitness matters for .NET applications for the following reasons: 对于.NET应用程序而言,这一点很重要,原因如下:

  • a DAC (data access control) library (mscordakwks.dll) of the correct bitness is needed. 需要具有正确位数的DAC(数据访问控制)库(mscordakwks.dll)。 There's no cross-bitness DAC available. 没有可用的交叉位DAC。
  • the debugger needs to be able to load the SOS debugging extension of the correct bitness 调试器需要能够加载正确位数的SOS调试扩展

It is not possible to convert a dump from 64 bit to 32 bit, although in theory it should contain all necessary information. 将转储从64位转换为32位是不可能的,尽管理论上它应该包含所有必要的信息。

If you're feeling lucky, you can also try some of the instructions anyway 如果你感到幸运,你也可以尝试一些指示

How to detect the bitness of an application? 如何检测应用程序的位数?

If you don't know the bitness, you can find it out like this: 如果你不知道它的位数,你可以这样找到它:

Windows 7 Task Manager shows *32 on processes: Windows 7任务管理器在进程上显示*32 Windows 7任务管理器

In Windows 8 task manager, go to the Details tab and add a column named Platform : 在Windows 8任务管理器中,转到“ Details选项卡并添加名为“ Platform的列: Windows 8任务管理器

Visual Studio shows the bitness when attaching to the process: Visual Studio在附加到进程时显示位数: Visual Studio中的比特

Process Explorer can be configured to show the Image Type column: 可以将Process Explorer配置为显示“ Image Type列: Process Explorer中的位数

Tools 工具

Programs which detect bitness automatically: 自动检测位数的程序:

Tools which capture a dump with specific bitness: 捕获具有特定位数的转储的工具:

  • 64 Bit: default Task Manager on a 64 bit OS 64位:64位操作系统上的默认任务管理器
  • 32 Bit: Task manager run from %windir%\\SysWOW64\\taskmgr.exe on a 64 Bit OS 32位:任务管理器在64位操作系统上从%windir%\\ SysWOW64 \\ taskmgr.exe运行
  • 64 Bit: ProcDump run with the -64 command line switch 64位: ProcDump使用-64命令行开关运行
  • 32 Bit: WinDbg x86 version 32位:WinDbg x86版本
  • 64 Bit: WinDbg x64 version 64位:WinDbg x64版本
  • 32 Bit: DebugDiag x86 version 32位:DebugDiag x86版本
  • 64 Bit: DebugDiag x64 version 64位:DebugDiag x64版本
  • 32 Bit: ADPlus x86 version 32位:ADPlus x86版本
  • 64 Bit: ADPlus x64 version 64位:ADPlus x64版本

Just choose the bitness according to your application, not according the OS. 只需根据您的应用选择位数,而不是根据操作系统。

Why is memory relevant here? 为什么内存与此相关?

For .NET you need a full memory dump, otherwise you cannot figure out the content of the objects. 对于.NET,您需要一个完整的内存转储,否则您无法弄清楚对象的内容。 To include full memory, do the following: 要包含完整内存,请执行以下操作:

  • in WinDbg, specify /ma when doing .dump 在WinDbg中,在执行.dump时指定/ma
  • in Process Explorer , choose "Create full dump" (although technically, the result is still a minidump) Process Explorer中 ,选择“Create full dump”(虽然从技术上讲,结果仍然是minidump)
  • in ProcDump , apply the -ma command line switch ProcDump中 ,应用-ma命令行开关
  • in Visual Studio, choose "Minidump with heap" 在Visual Studio中,选择“带堆的Minidump”
  • Task Manager will always create a dump with full memory 任务管理器将始终创建具有完整内存的转储
  • For Windows Error Reporting LocalDumps set DumpType to 2 对于Windows错误报告LocalDumpsDumpType设置为2

Visual Studio instructions Visual Studio说明

I found out that many developers aren't even aware that Visual Studio can create dumps. 我发现很多开发人员甚至都不知道Visual Studio可以创建转储。 The reason probably is that the menu is invisible for a long time. 原因可能是菜单长时间不可见。 These are the steps: 这些是步骤:

  • Start Visual Studio: menu is invisible 启动Visual Studio:菜单是不可见的
  • Attach to a process: menu is still invisible 附加到进程:菜单仍然不可见
  • Break: menu becomes visible (find it under Debug / Save dump as) 中断:菜单变得可见(在Debug / Save dump下找到它)

Why 64 bit dumps of 32 bit applications at all? 为什么要对32位应用程序进行64位转储?

Probably just for debugging the WoW64 layer itself. 可能仅用于调试WoW64层本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM