This is trivially easy with WinDBG, which is free from Microsoft. You will also want to install symbols for your version of Windows, if you don't have them already.
Simply setup WinDBG as your Crash Dump tool. I use this registry setting: (You may wish to edit the paths)
Sample: CrashDumpSettings.reg
:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Auto"="1"
"Debugger"="C:\\progra~1\\debugg~1\\cdb.exe -p %ld -e %ld -g -y SRV*c:\\mss*http://msdl.microsoft.com/download/symbols -c \"$<c:\\Dumps\\CrashDump.cdbscript\""
Here is what your CrashDump.cdbscript
might look like: (This is basically what I use... Edit the paths as appropriate.)
Sample: CrashDump.cdbscript
:
.sympath+ c:\windows\symbols;c:\some\path\to\symbols\for\your\project
as /c CrashFirstModule .printf "%mu", @@c++((*(ntdll!_LDR_DATA_TABLE_ENTRY**)&@$peb->Ldr->InLoadOrderModuleList.Flink)->BaseDllName.Buffer)
.logopen /t c:\dumps\${CrashFirstModule}_process.log
.kframes 100
!analyze -v
~*kv
lmv
.logclose
.dump /mhi /u /b c:\dumps\${CrashFirstModule}_mini.cab
.dump /mhia /u /b c:\dumps\${CrashFirstModule}_full.cab
q
And you get a nice log file and some dumps you can use to view the state of the process when the exception happened with WinDBG. The log file will have analysis of the error that occurred, including the line of code that caused the error. It will also list the call-stack for each thread. In the call stack listing, the thread with the #
next to it's number is the one that caused the exception. There is a TON of information in these files. I recommend picking up Debugging Applications for Microsoft .Net and Microsoft Windows by John Robbins. It's a great book on Debugging, even if it's from a few years ago. You can get it from Amazon for about $20.00.