Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Environment.FailFast Method (String, Exception)

.NET Framework 4.6 and 4.5

Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft.

Namespace:  System
Assemblies:   mscorlib (in mscorlib.dll)
  System.Runtime.Extensions (in System.Runtime.Extensions.dll)

public static void FailFast(
	string message,
	Exception exception


Type: System.String

A message that explains why the process was terminated, or null if no explanation is provided.

Type: System.Exception

An exception that represents the error that caused the termination. This is typically the exception in a catch block.

This method terminates the process without running any active try/finally blocks or finalizers.

The FailFast method writes the message string to the Windows Application event log, creates a dump of your application, and then terminates the current process.

Information is reported to Microsoft by using Windows Error Reporting. For more information, see Windows Error Reporting: Getting Started. Error reporting to Microsoft includes message and exception information, which provides details used to classify the error. Although exception is not handled because the process is terminated, the contextual information that raised the exception is still obtained.

If exception is null, or if exception is not thrown, this method operates the same as the FailFast(String) method overload.

Use the FailFast method instead of the Exit method to terminate your application if the state of your application is damaged beyond repair, and executing your application's try/finally blocks and finalizers will corrupt program resources.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

  • SecurityCriticalAttribute 

    requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

© 2015 Microsoft