System.Activities.Statements.TryCatch
Description
Catches a specified exception type in a sequence or activity.
Attributes
Misc
Display Name - Renames the activity.
Example
- Add a Try Catch activity inside the Workflow area.
- Inside the Sequence, create a String variable called variable1 and give it the default value of "Initial hello".
- Create a System.Object variable named variable2 and leave its default value blank.
- Drag and drop an Assign activity inside the Try field.
- In the Assign To input field
, enter variable1.
- In the Assign Value input field
, activity, enter variable2.ToString.
Your use case should now look like the following screenshot: - Click on the Add new catch button of the Catches field and select System.NullReferenceException from the Exception dropdown field.
- Drag and drop a Write Line activity inside the Catches field and enter exception.ToString in its Text input field.
Your use case should now look like the following screenshot: - Finally, click on the Add an activity button of the Finally field then drag and drop a Write Line activity inside the Finally field and enter variable1 in its Text input field.
Your use case should now look like the following screenshot:
The output should look like this in the Output panel: