Debugging Custom Activities
You must do the following to upload a custom activity to the FIM Portal and configure it so that it appears in the Workflow Designer:
Sign the assembly with a strong name.
Copy the assembly to the Global Assembly Cache (GAC) of the server that is hosting the FIM Service.
Start and stop the FIM Service.
Create an Activity Configuration Information resource that references the activity.
Run IISRESET.
For more information about the steps in the previous list, see Building the Assembly and Loading it into the FIM Portal and Configuring the Activity in FIM.
If you have successfully uploaded a custom activity to the FIM Portal and can view the activity in the Workflow Designer, then you should be able to debug the activity execution using Visual Studio as described in this topic if all of the following are true:
Visual Studio is installed on the computer that is hosting the FIM Service.
The custom activity that you installed on the FIM Portal was built using a Debug build.
Tip
If you did not upload a debug build of your custom activity then you must rebuild your activity in debug mode and upload the modified assembly file to the computer hosting the FIM Service to debug the activity.
The source code for the activity is stored on the computer that is hosting the FIM Service so that you can add breakpoints to the code where necessary.
If you have created a user interface (UI) for your activity, then you can debug the UI code by following the steps in Debugging Custom Activity UI in Visual Studio. If you have already created a workflow that includes your activity (as described in Creating a Workflow that Includes the Custom Activity) and a management policy rule (MPR) that runs that workflow (as described in Creating a Management Policy Rule to Run the Workflow), then you can debug the activity execution by following the steps in Debugging Custom Activity Code Using Visual Studio. You might want to consider adding a logging activity (such as the one created in How to: Create a Custom Logging Activity) to the workflow or custom activity to help debug the request associated with your activity.
Debugging Custom Activity Execution Using Visual Studio
If you have already created a workflow that includes your activity (as described in Creating a Workflow that Includes the Custom Activity) and a management policy rule (MPR) that runs that workflow (as described in Creating a Management Policy Rule to Run the Workflow), then you can debug the activity execution as described in the following procedure.
To debug custom activity execution in Visual Studio
Start Visual Studio.
Open the project that contains your custom activity.
Click Open, then Project/Solution from the File menu.
Browse to the folder that contains your custom activity code.
Click the project or solution file and click Open.
If the Solution Explorer is not displayed, select Solution Explorer from the View menu.
Right-click the project name in the Solution Explorer and click Set as StartUp project.
Right-click the file in the Solution Explorer that contains the code that you want to debug and click View Code.
Tip
In the custom activity example How to: Create a Custom Logging Activity, the relevant file to debug is RequestLoggingActivity.cs. A reasonable place to debug the Code activity included in the logging activity is the RequestLoggingActivity_ExecuteCode event handler.
Right-click the first line of code that you want to debug and select Breakpoint, then Insert Breakpoint. For more information, see Using Breakpoints and Tracepoints in Visual Studio.
Click Attach to Process in the Debug menu to open the Attach to Process dialog.
Select the Show processes from all users and Show processes in all sessions check boxes.
If the Attach to field is not set to Managed code, then do the following:
Click Select to open the Select Code Type dialog.
Click Debug these code types.
Select the Managed check box.
Click OK.
Select the process Microsoft.ResourceManagement.Service.exe.
The dialog should resemble the following illustration.
Click Attach.
If you receive a security warning message, click Attach.
Open the FIM Portal.
Create, delete, or modify a resource such that the MPR associated with your activity will be run.
Tip
In the How to: Create a Custom Logging Activity example, the MPR created in the Creating a Management Policy Rule to Run the Workflow procedure is run every time an administrator changes the Mobile Phone or Office Phone value of a user.
As soon as you submit your changes, you should see the execution of the activity stop on the breakpoint that you previously set.
Now you can use F10 (step over) or F11 (step in) keys to walk through your code. For more information, see Using Breakpoints and Tracepoints in Visual Studio.
Debugging Custom Activity UI in Visual Studio
If you have already created a workflow that includes your activity (as described in Creating a Workflow that Includes the Custom Activity) and a management policy rule (MPR) that runs that workflow (as described in Creating a Management Policy Rule to Run the Workflow), then you can debug the activity execution as described in the following procedure.
To debug custom activity UI in Visual Studio
Start Visual Studio.
Open the project that contains your custom activity.
Click Open, then Project/Solution from the File menu.
Browse to the folder that contains your custom activity code.
Click the project or solution file and click Open.
If the Solution Explorer is not displayed, select Solution Explorer from the View menu.
Right-click the project name in the Solution Explorer and click Set as StartUp project.
Right-click the file in the Solution Explorer that contains the CreateChildControls method for the custom activity and click View Code.
Tip
In the custom activity example How to: Create a Custom Logging Activity, the relevant file to debug is RequestLoggingActivitySettingsPart.cs.
Right-click the first line of code in the CreateChildControls method and select Breakpoint, then Insert Breakpoint.
For more information, see Using Breakpoints and Tracepoints in Visual Studio
Click Attach to Process in the Debug menu to open the Attach to Process dialog.
Select the Show processes from all users and Show processes in all sessions check boxes.
If the Attach to field is not set to Managed code, then do the following:
Click Select to open the Select Code Type dialog.
Click Debug these code types.
Select the Managed check box.
Click OK.
Select the process w3wp.exe, which is the IIS process.
Click Attach.
If you receive a security warning message, click Attach.
Open the FIM Portal.
In the FIM Portal, click the Workflows link.
Click New.
On the Basic Information tab, enter a value for Workflow Name attribute.
On the Basic Information tab, select a Workflow Type that corresponds to the type of activity that you want to debug.
Note
You associate your activity with one or more workflow types using the Activity Information Configuration resource associated with your custom activity. For an example of creating this resource, see Configuring the Activity in FIM.
Click Next. The Activity Picker should appear in the dialog box, and include your custom activity.
Click your custom activity in the Activity Picker and then click Select. You should see the execution of the activity stop on the breakpoint that you previously set.
Now you can use F10 (step over) or F11 (step in) keys to step through your code. For more information, see Using Breakpoints and Tracepoints in Visual Studio.