Catch<TException> Catch<TException> Catch<TException> Catch<TException> Class


Contains the actions to be executed after an exception is raised in the corresponding Try block of a Finally activity.

generic <typename TException>
 where TException : Exceptionpublic ref class Catch sealed : System::Activities::Statements::Catch
public sealed class Catch<TException> : System.Activities.Statements.Catch where TException : Exception
type Catch<'Exception (requires 'Exception :> Exception)> = class
    inherit Catch
Public NotInheritable Class Catch(Of TException)
Inherits Catch

Type Parameters


The type of exception that the Catch<TException> block is handling.



The following code sample demonstrates creating a Catch<TException> activity. This example is from the Fault Handling in a Flowchart Activity Using TryCatch sample.

FlowStep mwkStep = new FlowStep
    Action = new TryCatch
        DisplayName = "Try/Catch for Divide By Zero Exception",
        Try = new Assign
            DisplayName = "discount = 15 + (1 - 1/numberOfKids)*10",
            To = new OutArgument<double>(discount),
            Value = new InArgument<double>((ctx) => (15 + (1 - 1 / numberOfKids.Get(ctx)) * 10))
        Catches = 
             new Catch<System.DivideByZeroException>
                 Action = new ActivityAction<System.DivideByZeroException>
                     Argument = ex,
                     DisplayName = "ActivityAction - DivideByZeroException",
                     Handler =
                         new Sequence
                             DisplayName = "Divide by Zero Exception Workflow",
                             Activities =
                                new WriteLine() 
                                    DisplayName = "WriteLine: DivideByZeroException",
                                    Text = "DivideByZeroException: Promo code is MWK - but number of kids = 0" 
                                new Assign<double>
                                    DisplayName = "Exception - discount = 0", 
                                    To = discount,
                                    Value = new InArgument<double>(0)
    Next = flowDecision


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.


Catch<TException>() Catch<TException>() Catch<TException>() Catch<TException>()

Creates a new instance of the Catch<TException> class.


Action Action Action Action

The handler for the exception being caught.

ExceptionType ExceptionType ExceptionType ExceptionType

The type of exception that the Catch block is handling.


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to