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:

  1. Sign the assembly with a strong name.

  2. Copy the assembly to the Global Assembly Cache (GAC) of the server that is hosting the FIM Service.

  3. Start and stop the FIM Service.

  4. Create an Activity Configuration Information resource that references the activity.

  5. 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:

  1. Visual Studio is installed on the computer that is hosting the FIM Service.

  2. 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.

  3. 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

  1. Start Visual Studio.

  2. 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.

  3. If the Solution Explorer is not displayed, select Solution Explorer from the View menu.

  4. Right-click the project name in the Solution Explorer and click Set as StartUp project.

  5. 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.

  6. 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.

  7. Click Attach to Process in the Debug menu to open the Attach to Process dialog.

  8. Select the Show processes from all users and Show processes in all sessions check boxes.

  9. 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.

  10. Select the process Microsoft.ResourceManagement.Service.exe.

    The dialog should resemble the following illustration.

    The Attach To Process dialog.

  11. Click Attach.

  12. If you receive a security warning message, click Attach.

  13. Open the FIM Portal.

  14. 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

  1. Start Visual Studio.

  2. 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.

  3. If the Solution Explorer is not displayed, select Solution Explorer from the View menu.

  4. Right-click the project name in the Solution Explorer and click Set as StartUp project.

  5. 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.

  6. 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

  7. Click Attach to Process in the Debug menu to open the Attach to Process dialog.

  8. Select the Show processes from all users and Show processes in all sessions check boxes.

  9. 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.

  10. Select the process w3wp.exe, which is the IIS process.

  11. Click Attach.

  12. If you receive a security warning message, click Attach.

  13. Open the FIM Portal.

  14. In the FIM Portal, click the Workflows link.

  15. Click New.

  16. On the Basic Information tab, enter a value for Workflow Name attribute.

  17. 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.

  18. Click Next. The Activity Picker should appear in the dialog box, and include your custom activity.

  19. 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.

See Also

Concepts

Troubleshooting Forefront Identity Manager Service