views:

183

answers:

3

Hi,

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.

A: 

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);
  }
}
Ngu Soon Hui
He asked for a dump file. If you want to be notified about exceptions, AppDomain.UnhandledException is a better choice.
Patrik
+1  A: 

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.

Mez
+1  A: 

Hi there.

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.

Cheers. Jas.

Jason Evans