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)

适用于