简体   繁体   中英

Crash C# Application and Generate Dumps

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在此处输入图像描述

This is my settings for the dumps in the registry:

在此处输入图像描述

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM