With the help of "plugin registration" we can debug the custom workflow. You must first define/register your custom workflow in the CRM by adding steps in your process. Follow the below steps to debug it.
1) Open the plugin registration tool and connect to CRM.
2) If you don’t have the Profiler installed, click the “Install Profiler” button which is showing below
3) After Profile installing, plugin registration tool shows “Uninstall Profiler” button and a new item ‘Plug-in Profiler’ is added in the registered components as shown below.
4) On select of Plugin-in profiler you will find “Profile Workflow” button in the top menu click on that button
5) In profile settings window select your workflow in the workflow dropdown and steps will be automatically populate check it and select radio button “Persist to Entity “ and note that “Persistence Key” value for future use and then Click on “ok” .
6) After click ok button. If the error occurs "Automatic workflow cannot be published if no activation parameters have been specified" then you have to configure workflow in CRM as "On Demand" to solve this error.
7) Notice the Profiled item added as the sub item to the Plugin-in Profiler.
8) Go to process now you can see your selected workflow added with name embedded with profiled.(i.e., On Purchase Order Receive Email to Estimator (Profiled))
9) Now you can Trigger the relevant workflow.
10) Once you triggered the workflow. Go to "plugin profiles" in below location i.e., Go to Settingsà Extensionsà Plug-in Profiles.
11) Open the Relevant Plugin-in Profile record, make sure the Persistence key matches the one you have copied earlier.
12) Now open the Serialized Profile tab and copy the text and save that in new text file.
13) Now open the plugin registration tool and select plug-in profile then debug button will be displayed click on that button.
14) In the opened debug window select the newly created text file in the profile field and in the assembly Location select the custom workflow activity assembly (dll).
15) Now go to the visual studio and place some break point in code then attach to process as shown below
16) In available Process select the “Plugin Registration tool” as below
17) Click the Start Execution button in the Plugin Registration Tool debug window.
18) Now Breakpoint should be hit and from now on you can edit your code and debug locally.