How to: Create a Custom Activity Library
Microsoft® Forefront Identity Manager 2010 (FIM) lets you create custom activities and workflows. These activities can be included in a workflow created by using Windows Workflow Foundation (WF), or in a FIM custom workflow. Creating custom authentication activities requires a different procedure and will be covered in another topic.
To create a FIM custom activity, you must have .NET Framework version 3.5 installed.
This topic explains how to set up a workflow library to contain FIM custom activities. Other topics that show how to build custom activities will assume that a library similar to this has been created. For an end-to-end example of creating a custom activity, see How to: Create a Custom Logging Activity.
To create a FIM Custom Activity Library
Start Visual Studio 2008.
Create a new Workflow Activity Library. This example uses Visual C#, but Visual Basic can also be used.
On the File menu, click New and then click Project.
Under the Visual C# project types, select Workflow. In the Templates pane, select Workflow Activity Library.
Give the library a name and then click OK. For this example we named the project FIM.CustomWorkflowsActivityLibrary.
Add references to the FIM assemblies:
If the Solution Explorer is not open, on the View menu, click Solution Explorer.
In Solution Explorer, right-click the References folder, and then click Add Reference.
In the Add Reference dialog box, click the Browse tab, and browse to folder that contains the
The default installation location for this assembly is C:\Program Files\Microsoft Forefront Identity Manager\2010\Service.
Select the Microsoft.ResourceManagement.dll assembly, and then click OK.
Give the assembly a strong name so that it can be placed in the Global Assembly Cache (GAC).
Custom activities must be signed in order to for them to load correctly and be displayed in the Workflow Designer in the FIM Portal. See How to: Sign an Assembly with a Strong Name.
In Solution Explorer, right-click the Properties folder and then click Open.
This will open a tab in the workspace that has the same name as your project.
Select the Signing tab and select the Sign the assembly check box. Select a strong name key file from the drop-down list or select <New> and create a new key file name. In this example, we named the key file FIM.CustomActivitiesLibrary.
Clear the Protect my key file with a password check box.
Set application properties.
Select the Application tab of the dialog that was opened in the previous step.
In Assembly name type "FIM.CustomActivityLibrary". You can use any assembly name that does not already exist in the Global Assembly Cache (GAC) of the machine that is hosting the FIM Service.
In Default namespace type "FIM.CustomActivityLibrary.Activities".
In Target Framework, select .Net Framework 3.5.
Close the file.
Add the FIM activities to the Toolbox. Skip this step if there is already a tab that contains all FIM activities from the ResourceManagement.dll assembly.
If the Activity1.cs [Design] tab is not already open, right-click on the "Activity1.cs" file in the Solution Explorer and select View Designer.
Select the Activity1.cs [Design] tab.
If the Toolbox is not open, click the View menu and select Toolbox.
Right-click the Toolbox and select Add Tab. Rename the new tab FIM Activities.
Right-click the new tab and select Choose Items….
In the Choose Toolbar Items dialog box, click the Activities tab.
Click the Clear button to remove other activities from the tab.
Click Browse… and browse to the Microsoft.ResourceManagement.dll assembly installed with FIM.
Check each checkbox next to activities in the Microsoft.ResourceManagement.Workflows.Activities namespace that you want to include in the toolbox. See Microsoft.ResourceManagement.Workflow.Activities for information about which activities are supported.
Your workspace should now resemble the following illustration.
Build the project by selecting Solution from the Build menu.
Save the project by selecting Save All from the File menu.
It can be helpful to create separate folders for the project to separate activity code from UI code for the activity.
Right-click the project folder in the Solution Explorer. In our example the folder is named "FIM.CustomWorkflowsActivityLibrary."
Click Add and then click New Folder.
Name the new folder "Activities".
Right-click the project folder in the Solution Explorer.
Click Add and then click New Folder.
Name the new folder "WebUIs".
Delete the "Activity1.cs" activity by right-clicking the activity in the Solution Explorer and then clicking Delete.
You can now create custom activities in this library or add custom activities created in other Visual Studio projects to this library. For each activity you create in the project or add to the project, create a folder in the "Activities" folder that has the same name as your activity. Add activity code files to that folder and set the namespace of that activity to be "FIM.CustomActivityLibrary.Activities".
If your activity has a UI, you should create an additional folder in the "WebUIs" folder that has the same name as your activity. Add the class that defines the UI for your activity (the class that implements Microsoft.IdentityManagement.WebUI.Controls.ActivitySettingsPart) to that folder. Set the namespace of that activity to be "FIM.CustomActivityLibrary.WebUI".
For an end-to-end example of creating a custom activity, uploading the activity to the FIM server, and running that activity, see How to: Create a Custom Logging Activity.
How to: Create a Custom Logging Activity
Custom Activities and Workflows
Developing Custom Activities and Workflows
Debugging Custom Activities