WorkflowApplicationUnhandledExceptionEventArgs.ExceptionSourceInstanceId 속성

정의

처리되지 않은 예외의 소스인 활동 인스턴스의 고유 식별자를 가져옵니다.

public:
 property System::String ^ ExceptionSourceInstanceId { System::String ^ get(); };
public string ExceptionSourceInstanceId { get; }
member this.ExceptionSourceInstanceId : string
Public ReadOnly Property ExceptionSourceInstanceId As String

속성 값

처리되지 않은 예외의 소스인 활동 인스턴스의 식별자입니다.

예제

다음 예제에서는 예외를 throw하는 워크플로를 호출합니다. 예외는 워크플로에서 처리되지 않으며 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();

설명

작업에서 예외가 throw되고 처리되지 않은 경우 기본 동작은 워크플로 인스턴스를 종료하는 것입니다. OnUnhandledException 처리기가 있는 경우 이 기본 동작을 재정의할 수 있습니다. 이 처리기는 워크플로 호스트 작성자에게 사용자 지정 로깅, 워크플로 중단, 워크플로 취소 또는 워크플로 종료와 같은 적절한 처리를 제공할 수 있는 기회를 제공합니다.

적용 대상