Monday 20 March 2017

How to debug a CRM Online Plugin?


When you develop plugins for Dynamics CRM unless it is a very simple scenario 9 out of 10 situations you will require to debug your plugin. One way of fulfilling this requirement is using the tracing which is bit easier. But sometimes this is not sufficient. So you have no other choice but debug the plugin!

With Dynamics CRM online debugging a plugin is not very straight forward. With On-Premise environments you can run the remote debugger on the CRM server and attach to the process in you visual studio and proceed. But in the cloud version with the limited access this is not possible. So here is how you do it:

Start Plugin Registration Tool in the SDK and connect to your CRM organisation.

If this is the first time someone is going to debug a plugin in this organisation you will see the button “Install Profiler” in the menu bar. (Otherwise profiler will be installed already) Click on it and it will start installing profiler. 





Then register you plugin and the steps. Select the step which you want to debug and click "Start Profiling".


































Here you select the option “Exception” and click Ok.


Now in CRM perform the operation where your plugin is supposed to trigger. (In this example it triggers when multiple accounts are retrieved. So I open the Accounts view).

You will get a business process error. Click Download Log File and save the log file into your local drive.














Then open your plugin code in visual studio; set the break points; click Attach to process under the debug menu. Select the PluginRegistration.exe from the available processes and click attach.


Then in the plugin registration tool click “Debug” from the menu.
For the Profile browse to the downloaded error log file and in the previous step and select it.
Select your plugin dll for the Assembly location and then the plugin.

Then click Start Execution.




Debugger will hit your breakpoints you had set up in Visual Studio and you can continue debugging your code with pressing F10.

Once you are done with debugging make sure you go back to the plugin registration tool; select the step in your plugin and click “Stop Profiling”; otherwise you will always get business process error when you perform your operation!


Happy debugging J 



No comments:

Post a Comment

How to tackle Concurrent Business Process flows

Dynamics 365 has introduced the new feature of Concurrent Business Process Flows. Here is a couple of good articles on that: http://dev...