Plugin Debugging for Dynamics CRM 365 (Online)


In this blog, we will discuss the issues we face during the debugging of a plugin in an Online environment of Dynamics 365 CRM. We will learn how to set up a Plugin Profiler and solve the problems related to debugging by identifying and tracking down the problems in the “logic” behind the plugins.

Learn more about our Dynamics 365 offerings 
Let’s begin, shall we?

Downloading CRM SDK V9.X

For CRM connectivity, you need to download the Dynamics CRM SDK v9.x using the PowerShell command.

Open PowerShell using RUN (press Win key + R).

PowerShell using RUN

Create a new folder with the name SDK_V9 on your C drive and change the directory in PowerShell using the following command:

cd c:\sdk_v9

Copy and paste the following command to download the SDK V9.0 in the folder.


$sourceNugetExe =
$targetNugetExe = ".\nuget.exe"
Remove-Item .\Tools -Force -Recurse -ErrorAction Ignore
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose

## Plugin Registration Tool
./nuget install Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool -O .\Tools
md .\Tools\PluginRegistration
$prtFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.'}
move .\Tools\$prtFolder\tools\*.* .\Tools\PluginRegistration
Remove-Item .\Tools\$prtFolder -Force -Recurse

## CoreTools
./nuget install Microsoft.CrmSdk.CoreTools -O .\Tools
md .\Tools\CoreTools
$coreToolsFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.CoreTools.'}
move .\Tools\$coreToolsFolder\content\bin\coretools\*.* .\Tools\CoreTools
Remove-Item .\Tools\$coreToolsFolder -Force -Recurse

## Configuration Migration
./nuget install Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf -O .\Tools
md .\Tools\ConfigurationMigration
$configMigFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.ConfigurationMigration.Wpf.'}
move .\Tools\$configMigFolder\tools\*.* .\Tools\ConfigurationMigration
Remove-Item .\Tools\$configMigFolder -Force -Recurse

## Package Deployer
./nuget install Microsoft.CrmSdk.XrmTooling.PackageDeployment.WPF -O .\Tools
md .\Tools\PackageDeployment
$pdFolder = Get-ChildItem ./Tools | Where-Object {$_.Name -match 'Microsoft.CrmSdk.XrmTooling.PackageDeployment.Wpf.'}
move .\Tools\$pdFolder\tools\*.* .\Tools\PackageDeployment
Remove-Item .\Tools\$pdFolder -Force -Recurse

## NuGet.exe Remove
Remove-Item nuget.exe

The tools will be downloaded to the folder.

PowerShell downloaded

Setting up the Plugin Registration Tool

Open the folder sdk_v9 and navigate to \Tools\PluginRegistration

Open the PluginRegistration.exe and click on Create New Connection.

PluginRegistration tool

Provide the ORG details and credentials as shown in the image below:

ORG details

After you log in, it will ask for the instances of your Organization. Select the Organization which has the plugin that you are attempting to debug.

To begin the debugging process, you will need to install the Plugin profiler in the Organization. Click on Install Profiler from the ribbon of the Plugin Registration Tool to install the Plugin Profiler.

debugging process

After the installation of the profiler is complete, a node will be added with the name “Plug-in Profiler”. It is highlighted in the image below:

Plug-in Profiler

A solution will also be added to the Dynamics CRM Instance as shown below, you will see it when you open the ORG:

Dynamics CRM Instance

Setting up the plugin to debug:

The next step is to select the plugins that you want to debug. Navigate to the plugin registration tool, select your desired “Step” and then from the Ribbon menu click on “Start Profiling”.

For example:

Setting up the plugin

A dialogue box titled “Profiler Settings” will appear. Choose your Settings, click OK and continue. It’s better to go with the “Recommended Settings” option.

Profiler Settings

You will see an updated Step name on the Plugin Registration Tool after the Step has profiled. The word “Profiled” would appear at the end of the plugin step. Refer to the image below:

plugin step


In the next step you need to trigger the plugin:

Exception: if you selected Exception in Profiler Settings, it will generate an exception and a log file when you perform the operation. Download and Save the file. You will need that later for further debugging.

Persist to Entity: if you selected Persist to Entity in Profiler Settings, it will generate a CRM Plugin Profile record with the serialized content. You can view it by redirecting to Setting>>>Plug-in Profiles.

Learn more about our Dynamics 365 offerings 

Setting up Visual Studio:

Now open the Plugin Code in the Visual Studio solution and add a breakpoint to the debug plugin code. Usually, this is added to the Execute function of the Plugin.

The next step is to attach the Plugin Registration tool with the Visual Studio. Navigate to “Debug” from the file menu, and then click on Attach to Process.

Setting up Visual Studio

Search for Pluginregistration.exe from the Available processes and click on Attach, if you can’t find any, click on Refresh and search again.

Available processes

Once the process is attached, go back to the Plugin Registration Tool and click on Debug.

the Plugin Registration Tool debug

You will see a dialogue box. Provide the following there:

  1. Plugin Profile:
    1. Incase if you chose exception while setting up the profile, provide the file we downloaded previously which contains the serialized information of the plugin.
    2. If you selected Persist to entity, then select the Profile Log from the CRM.
  2. Assembly location: the DLL file of the Visual Studio Plugin Solution.
  3. Plugin: Select the Plugin from the dropdown list.

Visual Studio Plugin Solution

Click on Start Execution to hit the breakpoint we inserted in Visual Studio. You can now debug the code.


In this blog, we learned how to set up the plugin profiler and debug a plugin in an online environment of CRM. I hope that this brings clarity and ease to your plugin dilemmas. Don’t hesitate to leave us a comment in case you have a question! You can also connect with our BOLDEnthusiasts by clicking here.

Happy debugging!

Leave a Reply

Your email address will not be published. Required fields are marked *