Using a custom activity

Activities that derive from Activity or its subclasses can be composed into larger workflows, or created directly in code. This article 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 (that is, loaded by an instantiating type generated by the build process) If the referencing activity is loaded dynamically (for example, 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.

Use 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 directive that refers to the custom activity project, and pass a new instance of the activity to Invoke.