Engage on Facebook Engage on Twitter Engage on LinkedIn Engage on GitHub components notes mobile card heart 2 infinite mirror 2 pricing support

How to Debug A Plugin in Dynamics CRM 2015 Online

By Rich Campbell

microsoft dynamics logo

In this blog post we will debug a plugin and walk through the steps to debugging successfully.  There are a few things you need to know to make it happen.

 

(1)    If you haven’t already setup the Dynamics CRM SDK, you need to get a copy from here

(2)    Inside the Tools folder of the SDK, you will find a program called PluginRegistration.exe

(3)    Once open, click “Create new connection”, like shown below:

Create New Connection Screenshot

   Once you’re logged in, it’s time to take a moment and look at the registered assemblies and the steps associated with them.  In this scenario, we’re going to simulate debugging the execute method inside the Init class in the PopulatePriceList assembly. 

(4)    After you’ve found the step you want to debug, it’s time to install a profiler on the step.  Look at the screenshot below for reference.

install profiler screenshot

 

What we’re doing now, after you complete step 4, is profiling the plugin.  When the plugin triggers now, (in this example on create of opportunity), it will throw an exception  we can use with the plugin registration tool that we can then eventually replay in the plugin registration tool to debug our plugin and see what the error is. In step five, we’re going to start the debug process.  Follow along closely because these steps can be a little confusing at first 😃

 

(5)    Go into the step that the error occurs at, and make the error happen.  This time, instead of getting a usual unexpected error, you will get a obfuscated profile.  Click on “Download Log file” and save it.

(6)    With the profile saved, it’s time to go back into the plugin registration tool and actually start debugging our plugin! Click the debug button as shown in the screenshot below.

plugin registration tool screenshot

Once you click debug, a window pops up that requires a few things to get going.

You need to load the profile file you got earlier (Error Details.txt by default), then load your assembly which is in the /bin/debug directory of your plugin, and finally attach your visual studio to the plugin registration tool process, like shown below.

attach visual studio to plugin registration tool process screenshot

That’s it! After you attach the process you’ll be replaying the error that just happened in your instance of CRM Online.  From here you’ll be able to debug and step over or into a function. As always, feel free to comment below if you have any questions and I’ll be happy to help!

 

Stay tuned for more in depth CRM blog posts from me in the near future.

 

 

 

Planning a DNN upgrade? Download our guide