I am trying to find how to take a crash dump of a managed .Net executable and then open the resulting .dmp file in Visual Studio 2008. I want to see where the exception is generated in the source code, the call stack and the value of the variables in the functions on the stack.
To simplify the task, I wrote a gadget that crashes:
...
class Program
{
static void Main(string[] args)
{
int a = 2;
if (!File.Exists(@"C:\Crasher\bin\Debug\file.txt"))
throw new FileNotFoundException();
}
}
...
I built DEBUG and ran it from outside Visual Studio. In windbg, I clicked "Attach to process" and selected my application. Then I typed the windbg command prompt window:
.dump /ma C:\crasher\bin\debug\dump.dmp
Then I opened the .dmp file in Visual Studio. I went to Tools-> Options-> Debugging-> Symbols and added the following:
http://msdl.microsoft.com/download/symbols (saved to local folder)
DLL, "" (, Kernel32.dll, gdi32.dll - , ), mscorlib.ni.dll. Symbol Microsoft .pdbs mscorlib.dll, mscorlib.ni.dll.
.pdb .exe, , . , , .exe , - , pdb mscorlib.ni.dll, .
? - ?
, mscorlib.ni.dll Microsoft Symbol Server, , - , Visual Studio.
- .