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
CodePudding user response:
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.
- In your Solution Explorer, right-click your project and select Properties
- In Properties, go to the Application option on the side menu
- 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.