This is an overview of the 4th Module of our Plugin Development Course. Where we have covered about the How to enable tracing and debug plugin in Dynamics 365 / CRM ?
Module 4: Tracing & Debug Plugin In Dynamics 365
- Tracing a Plugin in Dynamics 365 Customer Engagement Platform
- How to debug plugin in Dynamics 365 CRM On-premise
- How to debug plugin in Dynamics 365 CRM Online
Debugging Plug-in Made Easy for Dynamics CRM Online
Is Exception Handling one of the easiest ways to track values of variables used in C# plugin for Dynamics CRM Online? It was really helpful for me, when I found that developers can use the Profiler in the Plugin Registration Tool (It comes with the CRM SDK. If you are using CRM SDK 2013 go to SDK->Tools->pluginregistration.exe) to debug a C# plugin in a similar fashion, as we usually debug C# code. So this is the coolest tool for all the plugin developers out there and can be used readily. Below are some steps which I am going to highlight, while you go through the whole process.
1. This is the sample C# code which is supposed to be debugged. This code is responsible for creating an account in CRM online. Make sure to set at least one breakpoint, before following further steps. Note: You can set breakpoint after Step 12 too.
2.Open the Plugin Registration tool.
3.Click on Create New Connection and then Login.
4. Select the organization you would like to connect to and click Login
5. If a profiler is already installed, the screen will appear as shown below. I have the profiler, already installed for the organization I selected in step 4.
6. Select the Step within the plugin which needs to be debugged.
7. Click on “Start Profiling” and the dialog box shown below will be displayed.
8. Click Ok. Note: This will throw an exception on executing the intended plugin, which will be the form of log file, which will be used in next steps.
9. Now, in CRM Online, perform the action, which will trigger the plugin. In my case, the plugin is executed when I click on the save button, to create an account.
10. After the execution of the plugin, it will throw an exception in the form of Log file as shown below.
11. Download the Log file.
12. In Visual studio (I am currently working on Visual Studio 2012), Go to Debug –> Attach Process –> (In Available Processes) Select PluginRegistration.exe and click Attach. Note: If you haven’t set any breakpoints, you can set one now.
13. Go to Plugin Registration tool and click on Debug.
- Profile: Locate the Log which you downloaded in previous step
- Assembly Location: Location of your assembly
- Plugin: The plug-in which you are debugging
14. Click on Start Execution and in Visual Studio you can see that you are in debugging mode.
There you are!! Already in a debug mode and currently on a breakpoint, you had set earlier. You can debug it now in a usual way.
Special CARE to be taken after Debugging:
1) Be sure to stop the profiling by hitting Stop Profiling, in the Plugin Registration Tool, after your debug process is over. Otherwise, it will throw an error whenever you execute the plugin, as we have set plugin execution to Exception Mode.
2) If you made any changes to the plugin, be sure to deploy it, before plugin execution.
3) If you don’t want to use profiler, you can uninstall it by clicking Uninstall Profiler.
Also find More on Dynamix Academy :
- How to Debug Asynchronous Workflow in Dynamics 365
- Impersonation In Microsoft Dynamics 365/CRM Plugins
- Microsoft Dynamics CRM/365 Interview Question and Answers