System.Activities.Statements.TryCatch


Description

    Catches a specified exception type in a sequence or activity.


Attributes

    Misc

  • Display Name - Renames the activity.


Example

  1. Add a Try Catch activity inside the Workflow area.
  2. Inside the Sequence, create a String variable called variable1 and give it the default value of "Initial hello"
  3. Create a System.Object variable named variable2 and leave its default value blank.
  4. Drag and drop an Assign activity inside the Try field.
  5. In the Assign To input field , enter variable1.
  6. In the Assign Value input field , activity, enter variable2.ToString.

    Your use case should now look like the following screenshot:



  7. Click on the Add new catch button of the Catches field and select System.NullReferenceException from the Exception dropdown field.
  8. 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:


  9. 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: