Using a custom activity

Activities that derive from Activity or its subclasses can be composed into larger workflows, or created directly in code. This topic describes how to use custom activities in workflows created either in code or in the designer.

Note

Custom activities can be used in the same project in which they are defined, as long as both the custom activity and the activity that uses it are compiled (i.e. loaded by an instantiating type generated by the build process) If the referencing activity is loaded dynamically (e.g. using ActivityXAMLServices), then the referenced assembly should be placed in a different project, or the designer-generated XAML needs to be hand-edited to enable this.

Using a custom activity to a workflow project

  1. Add a reference from the host project to the activity library project containing the custom activity.

  2. Build the solution.

  3. To use the custom activity in the designer, locate the custom activity in the toolbox, and drag the activity onto the designer surface.

  4. To use the custom activity in code, add a Using statement that refers to the custom activity project, and pass a new instance of the activity to Invoke.