Crash C# Application and Generate Dumps

641 views Asked by At

I'm trying to generate dumps for my C# application, I used the FailFast method to "Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and optional exception information in error reporting to Microsoft."

static void Main(string[] args)
        {
        string causeOfFailure = "This is a test crash.";
            try
            {
                Environment.FailFast(causeOfFailure);
            }
            finally
            {
                Console.WriteLine("This finally block will not be executed.");
            }}

I managed to get the error on event viewer, however Dumps are not generated enter image description here

This is my settings for the dumps in the registry:

enter image description here

I kept default values, so the Dump folder should be %LOCALAPPDATA%\CrashDumps However, no dumps are generated

1

There are 1 answers

1
DSander On BEST ANSWER

I see in your event viewer screenshot that your app uses .NET Framework 2.0. It seems the crash dump only works in .NET Framework 4.0 and above. Try changing the targeted .NET Framework.

  1. In your Solution Explorer, right-click your project and select Properties
  2. In Properties, go to the Application option on the side menu
  3. Locate the Target framework dropdown and select the framework version 4.0 or above.

I tested this on my machine. When targeting .NET 2.0 there is no crash dump. When targeting .NET 4.0 I get a crash dump.