WorkflowApplicationUnhandledExceptionEventArgs クラス

定義

ワークフロー インスタンスで発生した未処理の例外についての情報を提供します。

public ref class WorkflowApplicationUnhandledExceptionEventArgs : System::Activities::WorkflowApplicationEventArgs
public class WorkflowApplicationUnhandledExceptionEventArgs : System.Activities.WorkflowApplicationEventArgs
type WorkflowApplicationUnhandledExceptionEventArgs = class
    inherit WorkflowApplicationEventArgs
Public Class WorkflowApplicationUnhandledExceptionEventArgs
Inherits WorkflowApplicationEventArgs
継承
WorkflowApplicationUnhandledExceptionEventArgs

次の例では、例外をスローするワークフローを呼び出しています。 ワークフローで例外が処理されないため、OnUnhandledException ハンドラーが呼び出されます。 例外に関する情報を提供するために WorkflowApplicationUnhandledExceptionEventArgs が調査され、ワークフローは終了します。

Activity wf = new Sequence
{
    Activities =
     {
         new WriteLine
         {
             Text = "Starting the workflow."
         },
         new Throw
        {
            Exception = new InArgument<Exception>((env) =>
                new ApplicationException("Something unexpected happened."))
        },
        new WriteLine
         {
             Text = "Ending the workflow."
         }
     }
};

WorkflowApplication wfApp = new WorkflowApplication(wf);

wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
    // Display the unhandled exception.
    Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
        e.InstanceId, e.UnhandledException.Message);

    Console.WriteLine("ExceptionSource: {0} - {1}",
        e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);

    // Instruct the runtime to terminate the workflow.
    return UnhandledExceptionAction.Terminate;

    // Other choices are UnhandledExceptionAction.Abort and
    // UnhandledExceptionAction.Cancel
};

wfApp.Run();

注釈

アクティビティからスローされた例外が処理されない場合、既定の動作では、ワークフロー インスタンスが終了します。 OnUnhandledException ハンドラーが存在する場合、このハンドラーで既定の動作をオーバーライドできます。 このハンドラーがあると、ワークフロー ホストの作成者は、カスタムのログ記録、ワークフローの中止、ワークフローのキャンセル、ワークフローの終了などの適切な処理を実行できます。

プロパティ

ExceptionSource

未処理の例外の原因となったアクティビティを取得します。

ExceptionSourceInstanceId

未処理の例外の原因となったアクティビティ インスタンスの一意の識別子を取得します。

InstanceId

ワークフロー インスタンスの一意の識別子。

(継承元 WorkflowApplicationEventArgs)
UnhandledException

ワークフロー インスタンスによって処理されなかった Exception を取得します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetInstanceExtensions<T>()

指定された型の拡張機能のコレクションを取得します。

(継承元 WorkflowApplicationEventArgs)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象