I have been using the Plugin Registration Tool to debug Plugins for sometime now and it has turned out to be a real time saver as it let’s you run and debug your code without having to trigger application events. This shortens debug cycles and allows Plugins debugging by multiple developers simultaneously without halting the W3WP process.
I have just found out the Plugin Registration Tool can also help debug Custom Workflow Activities as well. Since this feature is currently not documented in the SDK or any other official literature, this post will guide you through.
Please note, currently this feature is not functioning well in Online deployments, hope MS will fix this soon.
In order to debug a Custom Workflow Activity, follow these steps:
- Activate the Plugin Registration Tool as an administrator. Make sure you are using the latest Plugin Registration Tool version from the latest SDK package.
- Register your Custom Workflow Activity using the Plugin Registration Tool.
- Create a Workflow Rule which reference your Custom Workflow Activity.
- If you don’t have the Profiler installed, click the ‘Install Profiler’ button in the inner menu. After it finishes installing, the Plugin Registration Tool shows the ‘Uninstall Profiler Button’ and a new item ‘Plug-in Profiler’ is added to the registered components
- Click the ‘Plug-in Profiler’ item. Note the ‘Profile Workflow’ button appearing in the inner top menu
- Click the ‘Profile Workflow’ button to open the Profile Setting window. From the Workflow picklist, select the Workflow Rule which contains the Custom Workflow Activity requires debugging
- Check the Custom Workflow Activity requires debugging. Select ‘Persist to Entity’ radio option and click ‘OK’. Copy the value In the Persistence Key field to your clipboard
- Notice the Profiled item added under the Plug-in Profiler root
- Go to your CRM organization and trigger the relevant Workflow. In my example, this is a manual Workflow rule.
- Go to Settings –> Extensions –> Plug-in Profiles. If you can’t locate it, refresh the window.
- Open the relevant Plug-in Profile record, make sure the Persistence Key matches the one you have copied earlier
- Click the Serialized Profile tab and copy the value in the Serialized Profile filed
- Create a new text file and copy the Serialized Profile string into it. Save the file
- Go Back to the Plugin Registration Tool, select the profile created earlier and click the Debug button in the inner toolbar
- In the opened Debug window, select the newly created text file in the the Profile Location field and the Custom Workflow Activity assembly in the Workflow Activity field
- Go to Visual Studio, where the Custom Workflow Activity project is opened. Compile your code and locate the Custom Workflow Activity assembly and PDB file in the “…\Program Files\Microsoft Dynamics CRM\Server\bin\assembly” folder
- Attach the debugger to the Plugin Registration Tool Process. Put some break point in your code and click the Start Execution button in the Plugin Registration Tool Debug Window.
You are done. The Breakpoint should be hit and from now on you can edit your code and debug locally against the Plugin Registration Tool.
Now go get productive.