There might come a time when you would like to use a debugging tool to identify bugs/issues in your plugin code and these plugins could be sync or async plugins. To do so we will use Visual Studio and registration tool.
Lets get started.
Step 1:
Run Registration tool > Click and install profile installer


Step 2:
Select plugin assembly > select step > start profiling

We have two different ways to debug a plugin as following:
- Exception(synchronous Plugins)
- Persist to entity(synchronous and asynchronous Plugins)
Step 3(a): Exception
Select exception

Step 3(b):
Trigger the event > Download the log


Step 3(c):
Select step > Click debug

Step 3(d):
Browse and add downloaded exception log into Profile section > Locate and load dll of the plugin


Before clicking on start execution, we have attach visual studio debugger with registration tool.
Step 3(e):
Click debug > Attach to Process > Find and select registration tool in list


Step 3(f):
Click execution



Exception are best suited for synchronous plugins and when there is a restriction of creating sample records.
Step 4(a): Presist to Entity
Select Presist to Entity > Click Ok


Step 4(b):
Trigger the event

Step 4(c):
Add profile > Add assembly > add plugin

Event which are triggered and profiled will be available in the list. As following:


Before clicking on start execution, we have attach visual studio debugger with registration tool.
Step 4(d):
Click debug > Attach to Process > Find and select registration tool in list
You can also use reattach button if registration tool is already attached before.


Step 4(e):
Click execution



Presist to entity is the only way to debug an asynchronous plugins.
With this we have covered, how to debug a plugin in MS Dynamics 365 CE. However, if you have any concerns or issues regarding plugins, comment, or get in touch. I will be happy to help.

