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”
1
Step 3: Click on login. It’ll ask for credentials.
Provide your dynamics 365 username and password and click sign in.2.PNG
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.
3.PNG
Once it’s done, it’ll look like this:
4.PNG
Also a solution is created in Dynamics CRM instance as shown below:
5.PNG

Step 6: Now select the step you want to debug in plugin registration tool and click Start Profiling.6
Click ok in next window:
7.PNG
As you click OK,the plugin step is updated as below:
8.PNG
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:
9.PNG
Step 9: Now click on debug in plugin registration tool as shown below:
10.PNG
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“:
11.PNG
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:
12.PNG

Now you can debug the code line by line further by pressing F10.
Hope this post was helpful.