Catches Property
Collapse the table of content
Expand the table of content

TryCatch.Catches Property

.NET Framework (current version)
 

The collection of Catch elements to be checked when the Try activity throws an exception.

Namespace:   System.Activities.Statements
Assembly:  System.Activities (in System.Activities.dll)

[DependsOnAttribute("Try")]
public Collection<Catch> Catches { get; }

Property Value

Type: System.Collections.ObjectModel.Collection<Catch>

The catch collection.

Catches are evaluated in the order in which they are added to the collection. If an exact match for the exception type is found, the matching Catch activity is executed. If no exact match is found, the Catch with the closest matching ExceptionType is executed.

The following code sample demonstrates setting the Catches property of a TransactionScope activity. This example is from the Nesting of TransactionScope within a service sample.

Once placed in the designer, Catch activities cannot be reordered in the designer. To reorder the collection of Catch activities, either delete and re-add them in the correct order, or use the xaml (code) view for the workflow.

.NET Framework
Available since 4.0
Return to top
Show:
© 2016 Microsoft