How to debug a plugin in Dynamics 365 online using plugin profiler
In this post we’ll learn how one can debug a plugin code in Dynamics 365 online or Dynamics CRM online environment.
What you need is dynamics 365 SDK which ou can download from here.
Below is the Step by Step procedure to debug a plugin in Dynaamics 365/Dynamics CRM online:
Step 1: Download and extract Dynamics 365 SDK in any folder.
Step 2: Now navigate to SDK\Tools\PluginRegistration
Here you’ll see pluginRegistration.exe file.
Double click on it and create a new connection.by clicking “Create New Connection”
Step 3: Click on login. It’ll ask for credentials.
Provide your dynamics 365 username and password and click sign in.
Step 4: Now it’ll display the available instances of your organization.
Select the one in which your plugin exist you want to debug.
It’ll display the list of existing assembly deployed in that instance.
Step 5: Click on install profiler button on top ribbon of Plugin Registration tool.
Once it’s done, it’ll look like this:
Also a solution is created in Dynamics CRM instance as shown below:
Step 6: Now select the step you want to debug in plugin registration tool and click Start Profiling.
Click ok in next window:
As you click OK,the plugin step is updated as below:
Step 7: Now perform the operation on which the above step has been registered.
It’ll generate an exception and a log file which you need to download and save.
It’ll be used in step 9.
Step 8: Now open the plugin solution in Visual studio and Add the breakpoint in plugin code from where you would like to debug.
Now click on debug and then click attach to process.
Below window will pop up where you need to select PluginRegistration.exe adn click on attach:
Step 9: Now click on debug in plugin registration tool as shown below:
Now below window will open where you need to select the log file downloaded in step 7 in Profile, specify plugin dll assembly location in Assembly location and select the step in Plugin as shown in below image and click “Start Execution“:
Step 10: As soon as you click on Start Execution, the debugger stops at the breakpoint inserted in code in step 8 as shown in below screenshot:
Now you can debug the code line by line further by pressing F10.
Hope this post was helpful.
In case you face difficulty in any step, please comment.
I’ve done exactly what you’ve written in the article, everything is fine until the step 9. At this step when I click “Debug” button nothing happens (Replay Plug-in Execution window just doesn’t open).
I’m trying to debug a plugin step that is registered in D365 v9.
Thanks in avance,
Sorry for late reply. I need to see if there is some issue you’r facing. I would recommend to test your plugin code in a console application if possible. It’s easy and convenient.
In trail org , 9 th step will not give any response.
its not work for Step 7
I have read so many posts about the blogger lovers however this post is
actually a nice post, keep it up.
LikeLiked by 1 person
For those experiencing problems:
To download the log file, you need to put your plugin in Synchronous mode. Asynchronous plugins don’t give you the option to download the log file, as these end up in the System Jobs.
I hope this helps you out!