Environment.FailFast メソッド

定義

エラー メッセージを報告する前に、プロセスを直ちに終了します。 Windows の場合、エラー メッセージは Windows アプリケーション イベント ログに書き込まれ、メッセージとオプションの例外情報は Microsoft へのエラー報告に含まれます。 Unix のようなシステムの場合、メッセージはスタック トレースと共に標準エラー ストリームに書き込まれます。

オーバーロード

FailFast(String)

エラー メッセージを報告する前に、プロセスを直ちに終了します。 Windows の場合、エラー メッセージは Windows アプリケーション イベント ログに書き込まれ、メッセージは Microsoft へのエラー報告に含まれます。 Unix のようなシステムの場合、メッセージはスタック トレースと共に標準エラー ストリームに書き込まれます。

FailFast(String, Exception)

エラー メッセージを報告する前に、プロセスを直ちに終了します。 Windows の場合、エラー メッセージは Windows アプリケーション イベント ログに書き込まれ、メッセージと例外情報は Microsoft へのエラー報告に含まれます。 Unix のようなシステムの場合、スタック トレースと共にメッセージが標準エラー ストリームに書き込まれます。

FailFast(String)

Source:
Environment.cs
Source:
Environment.cs
Source:
Environment.cs

エラー メッセージを報告する前に、プロセスを直ちに終了します。 Windows の場合、エラー メッセージは Windows アプリケーション イベント ログに書き込まれ、メッセージは Microsoft へのエラー報告に含まれます。 Unix のようなシステムの場合、メッセージはスタック トレースと共に標準エラー ストリームに書き込まれます。

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 で実行しているときに Windows アプリケーション イベント ログにログ エントリを書き込むか、Unix に似たシステムで実行しているときにエラー メッセージを標準エラー ストリームに書き込み、現在のプロセスを終了します。

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 ブロックまたはファイナライザーを実行せずにプロセスを終了します。

Windows では、 メソッドは Environment.FailFast 文字列を message Windows アプリケーション イベント ログに書き込み、アプリケーションのダンプを作成してから、現在のプロセスを終了します。 このmessage文字列は、Windows エラー報告を介した Microsoft へのエラー報告にも含まれています。 詳細については、「Windows エラー報告: はじめに」を参照してください。

Unix に似たシステムでは、メッセージはスタック トレース情報と共に標準エラー ストリームに書き込まれます。

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

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

適用対象

FailFast(String, Exception)

Source:
Environment.cs
Source:
Environment.cs
Source:
Environment.cs

エラー メッセージを報告する前に、プロセスを直ちに終了します。 Windows の場合、エラー メッセージは Windows アプリケーション イベント ログに書き込まれ、メッセージと例外情報は Microsoft へのエラー報告に含まれます。 Unix のようなシステムの場合、スタック トレースと共にメッセージが標準エラー ストリームに書き込まれます。

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 ブロックやファイナライザーを実行せずにプロセスを終了します。

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

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

Unix に似たシステムでは、メッセージはスタック トレース情報と共に標準エラー ストリームに書き込まれます。

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

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

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

適用対象