Crash dumps are very useful to debug an application. Recently, I worked on a Visual Studio extension we use in my company. It's very easy to develop such kind of application. However, there are lots of reasons for your extension to crash. Of course, you can add lots of try/catch, but you'll for sure forget the good one, so VS will crash. When it's happening, you would like to be able to attach a debugger and see the exception and the stack trace. Instead of attaching a debugger, you can automatically generate a crash dump that you can use to debug the application later.
In Windows, you can configure Windows Error Reporting (WER) to generate a dump when an application crashes.
- Open the key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps
- Set the value
DumpFolder(REG_EXPAND_SZ) to the directory you want the dump to be created
- Optionally, you can prevent WER to keep lots of crash dumps by setting
DumpCount(DWORD) to a low number
Maybe you prefer to set the configuration using PowerShell:
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "LocalDumps" New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "%LOCALAPPDATA%\CrashDumps" -PropertyType "ExpandString" New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Value 10 -PropertyType DWord
You can also configure WER per application. So, if you want to generate a full dump only for one application, you can create a key for your application under
LocalDumps with the configuration you want. If your application is
devenv.exe the key name is
devenv.exe. This is very simple!
Windows Error Reporting (WER) configuration
When your application crash, you can go to
Windows Error Reporting (WER) generated crash dump
Find the latest dump and open it using Visual Studio to start debugging the application. By default, it shows system information, the exception that crashes the application, and the list of modules. You can use the action section on the right to start the debugger and find more information about the exception.
Do you have a question or a suggestion about this post? Contact me!