How to: Configure Workflow Unhandled Exception Behavior with WorkflowServiceHost

The WorkflowUnhandledExceptionBehavior is a behavior that enables you to specify the action to take if an unhandled exception occurs within a workflow hosted in WorkflowServiceHost. This topic shows how to configure this behavior in a configuration file.

To configure WorkflowUnhandledExceptionBehavior

  1. Add a <workflowUnhandledException> element in a <behavior> element within a <serviceBehaviors> element, using the action attribute to specify the action to take when an unhandled exception occurs as shown in the following example.

        <behavior name="">  
          <workflowUnhandledException action="abandonAndSuspend"/>   


    The preceding configuration sample is using simplified configuration. For more information, see Simplified Configuration.

    This behavior can be configured in code as shown in the following example.

    host.Description.Behaviors.Add(new WorkflowUnhandledExceptionBehavior { Action = WorkflowUnhandledExceptionAction.AbandonAndSuspend });  

    The action attribute of the <workflowUnhandledException> element can be set to one of the following values:

    Aborts the instance in memory without touching the persisted instance state (that is, roll back to the last persist point).

    Aborts the instance in memory and updates the persisted instance to be suspended.

    Calls cancellation handlers for the instance and then completes the instance in memory, which may also remove it from the instance store

    Completes the instance in memory and removes it from the instance store.

    For more information about WorkflowUnhandledExceptionBehavior, see Workflow Service Host Extensibility.

See Also

Workflow Service Host Extensibility
Workflow Services