Debugging Workflow Custom Activities with Plugin Registration Tool

March 8, 2013

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:

  1. Activate the Plugin Registration Tool as an administrator. Make sure you are using the latest Plugin Registration Tool version from the latest SDK package.
  2. Register your Custom Workflow Activity using the Plugin Registration Tool.
  3. Create a Workflow Rule which reference your Custom Workflow Activity.
  4. 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

    image

  5. Click the ‘Plug-in Profiler’ item. Note the ‘Profile Workflow’ button appearing in the inner top menu

    image

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

    image

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

    image

  8. Notice the Profiled item added under the Plug-in Profiler root

    image

  9. Go to your CRM organization and trigger the relevant Workflow. In my example, this is a manual Workflow rule.

    image

  10. Go to Settings –> Extensions –> Plug-in Profiles. If you can’t locate it, refresh the window.

    image

  11. Open the relevant Plug-in Profile record, make sure the Persistence Key matches the one you have copied earlier

    image

  12. Click the Serialized Profile tab and copy the value in the Serialized Profile filed

    image

  13. Create a new text file and copy the Serialized Profile string into it. Save the file
  14. Go Back to the Plugin Registration Tool, select the profile created earlier and click the Debug button in the inner toolbar

    image

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

    image

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

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

28 comments

  1. santoshMarch 9, 2013 ב 12:46 AM

    Hello sir ,
    i am getting following error while proforming step7..

    Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
    at PluginProfiler.Library.WorkflowXamlUtility.InstrumentStep(XmlNode activityNode, XmlNamespaceManager ns, InstrumentedStepConfiguration step, String workflowAssemblyName)
    at PluginProfiler.Library.WorkflowXamlUtility.InstrumentXaml(IOrganizationService service, String xaml, IList`1 steps)
    at PluginProfiler.Library.ProfilerManagementUtility.EnableWorkflow(IOrganizationService service, String overrideKeyFileName, Guid workflowId, Boolean persistToEntity, String persistenceSessionKey, Boolean includeSecureInformation, Boolean isContextReplay, CustomActivityStep[] workflowSteps)
    at Microsoft.Crm.Tools.PluginRegistration.ProfilerSettingsForm.OKButton_Click(Object sender, EventArgs e)

    Reply
  2. Yaniv ArditiMarch 9, 2013 ב 2:12 AM

    Make sure you are using the latest SDK (5.0.14) and Plugin Registration Tool.
    Also try to use the ‘Exception’ radio option which means the context will be written into the Workflow instance error description, from which you can copy and use.

    Reply
  3. santoshMarch 9, 2013 ב 2:51 AM

    hello sir,

    i am using latest SDK (5.0.14) and Plugin Registration Tool.
    if i use the ‘Exception’ radio option then error is same ???

    Reply
  4. Yaniv ArditiMarch 9, 2013 ב 3:12 AM

    Did you run the Plugin Registration Tool as an administrator?

    Reply
  5. Larry McCoyJuly 19, 2013 ב 1:07 PM

    Excellent article! This is a game-changer for our team for debugging custom workflows. We have had so much trouble with configuring remote debugging that we had given up and resorted to throwing exceptions in our workflows to debug them. I’ve felt like was I back in the old days of C printf statements!!

    One question, once I’m done debugging, what is the supported method for removing the profile.

    Reply
  6. ScottJuly 23, 2013 ב 2:40 PM

    When I get to step 6 to pick a workflow, I get the following exception:

    System.ArgumentNullException: Value cannot be null.
    Parameter name: pluginAssemblyId

    I only get these for a handful of my custom workflows, not all of them. Unfortunately, Microsoft doesn’t give the source code anymore with the plug-in tool so I can’t step into the code and see where the problem lies.

    Anyone have any suggestions? These workflows (that throw the exception) work perfectly in CRM and have been incorporated into CRM the same as all other plugins.

    Reply
  7. ScottJuly 23, 2013 ב 4:11 PM

    I am also getting the same issue as reported by Santosh. Using most recent versions.

    Reply
  8. PiyushJuly 25, 2013 ב 7:40 AM

    Hi Yaniv, do you have any solution for the issue which Santosh has highlighted.
    I’m also getting the same error.

    Reply
  9. Hector VAugust 3, 2013 ב 10:00 PM

    I have same error as santosh.
    PluginProfiler.Library.WorkflowXamlUtility.InstrumentStep …
    Lastest SDK and CRM RollUps.

    Are you using a different LAB environment? or It could be the way you create or register your workflow assembly.
    I appreciate your help.

    Reply
  10. Victor JuarezFebruary 18, 2014 ב 10:39 AM

    I have the same problem at step 7: pluginAssemblyId cannot be null. Does anyone know the solution?
    Thank you

    Reply
    1. Muhammad SohailMay 6, 2014 ב 12:05 PM

      I have custom workflow and add the Plugin Profiler and when i unregistered assembly but workflow profiler is still present in workflow designer add step menu

      Reply
  11. rdt
    rdtMay 8, 2014 ב 11:25 AM

    I know many developers have encountered an error trying to use this method to debug Custom Activities with Plugin Registration Tool.
    I have contacted Microsoft on that matter but yet no reply.
    I will update when a relevant solution is found

    Reply
    1. sunilAugust 13, 2014 ב 9:55 AM

      Have you found the solution of this problem.. i am still facing this issue while dubuggin custom workflow activity.
      *value can not be null”

      Reply
    2. Prashanth KamasamudramNovember 26, 2015 ב 8:37 PM

      Yes you are right, this method is not working with online deployment, I tried to profile workflow but in popup its not listing all workflows, its just showing BPF and Enter Rule Name. None of custom workflow activities are being listed so cant debug them. :(. Hope Microsoft will fix it soon.

      Reply
    3. SergioMay 30, 2016 ב 10:21 PM

      I get the same error Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.with CRM 2015 when I try to debug a custom workflow.

      Have you received any notice about it from Microsoft?

      Thank you!

      Reply
      1. rdt
        rdtMay 31, 2016 ב 8:12 AM

        Sadly, no 🙁

        Reply
  12. RaulMay 26, 2014 ב 7:55 PM

    HI guys,

    In the CRM 2013 Online where is the option “Settings –> Extensions –> Plug-in Profiles”.

    I don’t see Extensions or plug-in profiles in the settings menu.

    Reply
    1. JahangirJuly 2, 2014 ב 10:30 AM

      Hi Raul,

      You can find plugin profile in crm 2013 online by hovering

      Setting -> Plugin profiles

      but before that you must have install profiler on plugin registration tool.

      Reply
  13. JensSeptember 11, 2014 ב 12:59 PM

    Hello, I also get the the error message “Object reference not set to an instance of an object.”

    Does anyone found a solution for this problem?

    Reply
    1. ichanOctober 14, 2014 ב 1:31 AM

      Hello,

      I am on Step#10 to view the Plugin Profiler on CRM extension, however there is nothing on the list of “Active Plug-in Profiles” or anywhere else. I checked the system job that it is in ‘waiting’ process. Below is a portion the error message that I have. Funny because running the workflow by itself doesn’t give this error message. It’s only when we try to profile it…

      Unhandled Exception: System.Activities.InvalidWorkflowException: The following errors were encountered while processing the workflow tree:
      ‘DynamicActivity’: The private implementation of activity ‘1: DynamicActivity’ has the following validation error: Compiler error(s) encountered processing expression “DirectCast(CustomActivityStep19: Check if Case User Owner belongs to Task Team_1_converted, System.String)”.
      Syntax error in cast operator; two arguments separated by comma are required.

      ‘DynamicActivity’: The private implementation of activity ‘1: DynamicActivity’ has the following validation error: Compiler error(s) encountered processing expression “CustomActivityStep19: Check if Case User Owner belongs to Task Team_1_converted”.
      End of expression expected.

      ‘DynamicActivity’: The private implementation of activity ‘1: DynamicActivity’ has the following validation error: Compiler error(s) encountered processing expression “CustomActivityStep19: Check if Case User Owner belongs to Task Team_1”.
      End of expression expected.

      Reply
  14. TarunAugust 5, 2015 ב 5:16 PM

    hello sir,

    Thanks a lot….!!!
    this is what I am looking for…
    nice article.

    Reply
  15. Pingback: Why Should You Always Debug with the Plugin Registration Tool | YanivRDT

  16. Pingback: Why Should You Always Debug with the Plugin Registration Tool | Yaniv Arditi

  17. Pingback: Why Should You Always Debug with the Plugin Registration Tool - Microsoft Dynamics CRM Community

  18. Pingback: CRM 2013 – Step by step guide to Remote Debugging – Hosk's Dynamic CRM Blog

  19. Pingback: CRM 2013 – Step by step guide to Remote Debugging - Microsoft Dynamics CRM Community

  20. rdt
    rdtJuly 3, 2016 ב 7:39 AM

    If you have trouble using the Plugin Registration Tool, take a look at this post
    https://dreamingincrm.com/2016/07/01/issues-in-debugging-custom-workflow-assemblies/

    Reply