Dump file believe that some friends are already familiar with the dump file is to save the process runtime stack information, to facilitate the future troubleshooting software, improve software quality. More about the Dump analysis tool WinDbg, ADPlus, if you don't know how to use it, please visit:
Use WinDbg to isolate deadlocks and resolve issues that are not responding to requests from software running in production environments
about ADPlus
pick up my previous article here: Send a patent ~ ~. NET high-order exception handling Topleveleh Continue, what should we do after catching the exception.
Generally speaking, we want to know the information about the program crash at that time, and also pop up the friendly dialog box, when the user clicks OK to close the program. The humble talk is like this:
MessageBox.Show ("The program crashes. "); Environment.exit (Environment.exitcode);
So the most critical thing to do, how to record the program crashes related dump information?!
Strong introduction:Dbghelp.dll. It is part of the Microsoft Debug Help library, which contains a set of debugging programs that allow you to work with executable images in the portable executable (PE) format. For more information, please visit MSDN.
Call it and you can generate the dump file directly, recording the running image of the program at that time.
Its method API is as follows:
[DllImport ("Dbghelp.dll", EntryPoint ="MiniDumpWriteDump", CallingConvention = callingconvention.stdcall, CharSet = charset.unicode, exactspelling =true, SetLastError =true)]
Static extern BOOLMiniDumpWriteDump (IntPtr hprocess,UINTProcessId, SafeHandle hfile,UINTDumptype,refminidumpexceptioninformation Expparam, IntPtr Userstreamparam, IntPtr callbackparam); //overload supporting Minidumpexceptioninformation = = NULL[DllImport ("Dbghelp.dll", EntryPoint ="MiniDumpWriteDump", CallingConvention = callingconvention.stdcall, CharSet = charset.unicode, exactspelling =true, SetLastError =true)]Static extern BOOLMiniDumpWriteDump (IntPtr hprocess,UINTProcessId, SafeHandle hfile,UINTDumptype, IntPtr Expparam, IntPtr Userstreamparam, IntPtr callbackparam);
How to use it?! Well, I know everyone likes to be lazy, I have written a class, we call directly on the OK. Just like this:
Minidumphelper.write (@ "C:\1.dmp", MiniDumpHelper.Option.WithFullMemoryInfo);
No diagram, no truth, compared to the Topleveleh before the use of the program:
And after using Topleveleh:
Here to remind you, debugging mode is not valid , specifically see my previous article . OK, then there is the dump file, and everything is done. Right?!
Source code: Click on me to download .
. NET high-order exception handling the second article ~ ~ Dump Advanced Minidumpwriter