TrackingWorkflowTerminatedEventArgs.Exception Property

 

Gets the exception that caused the workflow instance to be terminated.

Namespace:   System.Workflow.Runtime.Tracking
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)

public Exception Exception { get; }

Property Value

Type: System.Exception

The System.Exception that caused the workflow instance to be terminated.

When the workflow instance is terminated because of an unhandled exception, Exception contains the unhandled exception.

When the workflow instance is terminated by either a host call to WorkflowInstance.Terminate or by a TerminateActivity activity, Exception contains a WorkflowTerminatedException that has its Message property set to a description of the reason for the termination. If the host terminates the workflow instance, it supplies this description in the string parameter to WorkflowInstance.Terminate; if the workflow instance is terminated by a TerminateActivity, the description is supplied by TerminateActivity.Error.

The following code example demonstrates a method, named WriteTerminatedEventArgs, which captures a TrackingWorkflowTerminatedEventArgs. The code checks whether the Exception property is null (Nothing in Visual Basic). If it is not, the code writes the message associated with the Exception property to the console. If Exception is null (Nothing), the code does not write any exception information to the console.

This code example is part of the EventArgs Tracking SDK Sample from the Program.cs file. For more information, see EventArgs Tracking Sample.

static void WriteTerminatedEventArgs(string eventDescription, TrackingWorkflowTerminatedEventArgs terminatedEventArgs, DateTime eventDataTime)
{
    Console.WriteLine("\nTerminated Event Arguments Read From Tracking Database:\n");
    Console.WriteLine("EventDataTime: " + eventDataTime.ToString());
    Console.WriteLine("EventDescription: " + eventDescription);
    if (null != terminatedEventArgs.Exception)
    {
        Console.WriteLine("TerminatedEventArgs Exception Message: " + terminatedEventArgs.Exception.Message.ToString());
    }
}

.NET Framework
Available since 3.0
Return to top
Show: