TrackingWorkflowTerminatedEventArgs.Exception Property

Definition

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

public:
 property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
member this.Exception : Exception
Public ReadOnly Property Exception As Exception

Property Value

The Exception that caused the workflow instance to be terminated.

Examples

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());
    }
}
Shared Sub WriteTerminatedEventArgs(ByVal eventDescription As String, ByVal terminatedEventArgs As TrackingWorkflowTerminatedEventArgs, ByVal eventDataTime As DateTime)
    Console.WriteLine(vbCrLf + "Terminated Event Arguments Read From Tracking Database:")
    Console.WriteLine("EventDataTime: " + eventDataTime.ToString(CultureInfo.CurrentCulture))
    Console.WriteLine("EventDescription: " + eventDescription)
    If terminatedEventArgs.Exception IsNot Nothing Then
        Console.WriteLine("TerminatedEventArgs Exception Message: " + terminatedEventArgs.Exception.Message.ToString())
    End If
End Sub

Remarks

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.

Applies to

See also