Steps to Debug plug-in with profiler in CRM 2011

Steps to Debug plug-in with profiler in CRM 2011

Plug-in profiler is a very powerful debugging tool in CRM 2011. We can debug plug-ins with Plug-in profiler without connecting to CRM server or without remote debugging. By this, no need to re-deploy the plug-in to the Microsoft Dynamics CRM server until you have fixed the problem.

Below are the steps to debug the plug-in with profiler:

  1. Connect to CRM using plugin registration tool.
  2. Click on Install Profiler
  3. You will find a new node attached to registered plugins “Plugin Profiler”
  4. Select a plug-in step and click Profile to enable profiling
  5. Start your plugin from MSCRM i.e. if your plugin is on Create, perform Create operation.
  6. After the plug-in throws an exception and the Business Process Error dialog is displayed, click Download Log File and save this file. Alternately, if the plug-in does not throw an exception, click Stop Profiling.
  7. In the Plug-in Registration tool, click Debug
  8. In the Debug Existing Plug-in dialog box, provide the location of the previously saved log file.
  9. In Step #2, specify the location of the plug-in assembly
  10. Launch Visual Studio 2010 and attach the debugger to the PluginRegistration.exe process.
  11. Set a breakpoint in the plug-in code.
  12. Click Start Plug-in Execution in the Debug Existing Plug-in dialog box.
  13. After a slight delay, the plug-in will execute using the same execution context that was passed to it by the Microsoft Dynamics CRM server and the debugger will stop execution on the breakpoint that you previously set.
  14. Continue debugging the plug-in as you would normally do. Any traces that the plug-in outputs are shown in the Debug Existing Plug-in dialog box.

Note: The Plug-in Profiler is available in version 5.0.5 of the Microsoft Dynamics CRM SDK and later releases. Read more here on how to Analyze Plug-in Performance.