How can I take a dump file for Winforms application

自作多情 提交于 2019-12-11 16:07:34

问题


I have a C# application which is crashing for unknown reason.

For understanding the issue, i want to take a dump file for it.

How can i do it?

many thanks,

Oz.


回答1:


Are you talking about taking a minidump when your application crashes so you can debug it with windbg or cdb ?

If yes, there are different approaches:

DrWatson
-Run drwtsn32 -i at the commandprompt, this will activate dr watson and let it listen in the background for all crashes.

Windbg
-Run windbg -I from the commandpromt starting from the installation folder of Windbg.
-When a crash occurs, windbg will immediately load the crash dump.

Make sure you download and install the Debugging tools for Windows first.




回答2:


If you're using Windows Vista/7 or Server 2008, then you can open Task Manager and manually create a dump file, as explained here. I would recommend using Windbg for catching the crash, as Mez suggested, since then you can perform immediate crash dump analysis on the process.




回答3:


You must catch the exception and output it to a log file in your main.

i.e.,

static int main()
{
  try
  {
  }
  catch (Exception ex)
  {
    WriteToLogFile(ex);
  }
}


来源:https://stackoverflow.com/questions/1721111/how-can-i-take-a-dump-file-for-winforms-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!