Environment.FailFast メソッド

定義

メッセージを Windows アプリケーションのイベント ログに書き込んだ直後にプロセスを終了させ、Microsoft に送信するエラー レポートにそのメッセージとオプションの例外情報を含めます。

オーバーロード

FailFast(String)

メッセージを Windows アプリケーションのイベント ログに書き込んだ直後にプロセスを終了させ、Microsoft に送信するエラー レポートにそのメッセージを含めます。

FailFast(String, Exception)

メッセージを Windows アプリケーションのイベント ログに書き込んだ直後にプロセスを終了させ、Microsoft に送信するエラー レポートにそのメッセージと例外情報を含めます。

FailFast(String)

メッセージを Windows アプリケーションのイベント ログに書き込んだ直後にプロセスを終了させ、Microsoft に送信するエラー レポートにそのメッセージを含めます。

public:
 static void FailFast(System::String ^ message);
[System.Security.SecurityCritical]
public static void FailFast (string message);
public static void FailFast (string? message);
public static void FailFast (string message);
[<System.Security.SecurityCritical>]
static member FailFast : string -> unit
static member FailFast : string -> unit
Public Shared Sub FailFast (message As String)

パラメーター

message
String

プロセスが終了させられた原因を説明するメッセージ。説明を提供しない場合は null

属性

次の例では、Windows アプリケーション イベント ログにログ エントリを書き込み、現在のプロセスを終了します。

using System;

class Example
{
    public static void Main()
    {
       string causeOfFailure = "A catastrophic failure has occurred.";

       // Assume your application has failed catastrophically and must
       // terminate immediately. The try-finally block is not executed
       // and is included only to demonstrate that instructions within
       // try-catch blocks and finalizers are not performed.
       try
       {
           Environment.FailFast(causeOfFailure);
       }
       finally
       {
           Console.WriteLine("This finally block will not be executed.");
       }
   }
}
/*
The example produces no output because the application is terminated.
However, an entry is made in the Windows Application event log, and
the log entry contains the text from the causeOfFailure variable.
*/
open System

let causeOfFailure = "A catastrophic failure has occurred."

// Assume your application has failed catastrophically and must
// terminate immediately. The try-finally block is not executed
// and is included only to demonstrate that instructions within
// try-catch blocks and finalizers are not performed.
try
    Environment.FailFast causeOfFailure
finally
    printfn "This finally block will not be executed."

// The example produces no output because the application is terminated.
// However, an entry is made in the Windows Application event log, and
// the log entry contains the text from the causeOfFailure variable.
Module Example
    Public Sub Main()
        Dim causeOfFailure As String = "A catastrophic failure has occurred."
        ' Assume your application has failed catastrophically and must
        ' terminate immediately. The try-finally block is not executed 
        ' and is included only to demonstrate that instructions within 
        ' try-catch blocks and finalizers are not performed.

        Try
            Environment.FailFast(causeOfFailure)
        Finally
            Console.WriteLine("This finally block will not be executed.")
        End Try
    End Sub
End Module
'
' The code example displays no output because the application is
' terminated. However, an entry is made in the Windows Application event
' log, and the log entry contains the text from the causeOfFailure variable.

注釈

このメソッドは、アクティブな try/finally ブロックまたはファイナライザーを実行せずにプロセスを終了します。

このメソッドはEnvironment.FailFast、Windows アプリケーション イベント ログに文字列を書き込みmessage、アプリケーションのダンプを作成してから、現在のプロセスを終了します。 この message 文字列は、Microsoft へのエラー報告にも含まれています。

修復後に Environment.FailFast アプリケーションの状態が破損し、アプリケーションの Exit ブロックとファイナライザーを実行するとプログラム リソースが破損する場合は、メソッドの代わりにメソッドを使用してアプリケーション try/finally を終了します。

情報は、Windows エラー報告を使用して Microsoft に報告されます。 詳細については、「Windows エラー報告: はじめに」を参照してください。

Environment.FailFast Visual Studio デバッガーで実行されているアプリケーションの実行を終了するメソッドを呼び出すと、fatalExecutionEngineError マネージド デバッグ アシスタント (MDA) がスローExecutionEngineExceptionされ、自動的にトリガーされます。

適用対象

FailFast(String, Exception)

メッセージを Windows アプリケーションのイベント ログに書き込んだ直後にプロセスを終了させ、Microsoft に送信するエラー レポートにそのメッセージと例外情報を含めます。

public:
 static void FailFast(System::String ^ message, Exception ^ exception);
[System.Security.SecurityCritical]
public static void FailFast (string message, Exception exception);
public static void FailFast (string? message, Exception? exception);
public static void FailFast (string message, Exception exception);
[<System.Security.SecurityCritical>]
static member FailFast : string * Exception -> unit
static member FailFast : string * Exception -> unit
Public Shared Sub FailFast (message As String, exception As Exception)

パラメーター

message
String

プロセスが終了させられた原因を説明するメッセージ。説明を提供しない場合は null

exception
Exception

終了の原因となったエラーを表す例外。 通常、これは catch ブロックでの例外です。

属性

注釈

このメソッドは、アクティブな try/finally ブロックまたはファイナライザーを実行せずにプロセスを終了します。

このメソッドはEnvironment.FailFast、Windows アプリケーション イベント ログに文字列を書き込みmessage、アプリケーションのダンプを作成してから、現在のプロセスを終了します。

情報は、Windows エラー報告を使用して Microsoft に報告されます。 詳細については、「Windows エラー報告: はじめに」を参照してください。 Microsoft へのエラー報告には、エラーのexception分類に使用される詳細を提供する情報が含まれますmessageexceptionプロセスが終了するため処理されませんが、例外を発生させたコンテキスト情報は引き続き取得されます。

null場合exception、またはスローされない場合exception、このメソッドはメソッドのオーバーロードとFailFast(String)同じように動作します。

修復後に Environment.FailFast アプリケーションの状態が破損し、アプリケーションの Exit ブロックとファイナライザーを実行するとプログラム リソースが破損する場合は、メソッドの代わりにメソッドを使用してアプリケーション try/finally を終了します。

Environment.FailFast Visual Studio デバッガーで実行されているアプリケーションの実行を終了するメソッドを呼び出すと、fatalExecutionEngineError マネージド デバッグ アシスタント (MDA) がスローExecutionEngineExceptionされ、自動的にトリガーされます。

適用対象