How to Autogenerate Dump File using Windows Error Reporting : Easily Explained with Examples

 As Developers we might have faced situations wherein the application crashes and we are tasked to find out the reason for the crash. It can be quite challenging at first to identify the root cause of the crash. It can be anything from reading invalid memory location, or accessing memory which has already been de-allocated.

What is a Dump File?

Dump File is a file which gets generated by the Debugging engines which contains/embed information related to the state of the application during failure/crash to which the debugger is attached to.

 Dump files generated from these crashes serve as an important resource to identify the root cause with the help of call stack and associated information contained within the file.

Ways of Generating Dump Files

  • It can be generated manually from the Task Manager while the process is running by clicking on Create Dump File option from the context menu of the process as shown below:

                         Create Dump File from Task Manager

  • Dump File can also be generated using a custom utility or program which can be added in the Windows Registry : WindowsNT -> CurrentVersion -> AeDebug Option as shown in the figure below. This is an automatic way of generating the dump file when the application crashes.
AeDebug option for generating AutoDumps

  • Here we are going to discuss about an automatic way of generating the dump files using the Windows Error Reporting Functionality. For this we have to add few registry entries in the registry editor as shown below. We have to create the LocalDumps Folder if not present.
 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps.

Windows Error Reporting Dump Generation

 Once these Registry Entries are added then we can test whether the dump is getting generated in the location mentioned in the Registry by creating a Sample Application which raises an exception as shown below:

Application that raise an exception

The above is a basic Console Application in .NET Framework which raises an DivideByZero Exception.

When the application is executed an exception is raised which causes the application to crash. Let us check whether a dump file is present in the directory which we have mentioned in the Registry, which is apparently "D:\Dumps".

Dump Creation Directory


As shown in the figure above dump file is generated which can be used to analyze the source of exception.

Note : For more details related to the Registry Entries which needs to be added can check out the MSDN link




Comments

Popular posts from this blog

Creating RESTful Minimal WebAPI in .Net 6 in an Easy Manner! | FastEndpoints

Step By Step Guide to Detect Heap Corruption in Windows Easily

How to dynamically add Properties in C# .NET?