CRM 2011 – how to set up Remote debugging for plugins

A funny thing happened to me this week, I had created a plugin with another developer and when I deployed it, it refused to work.  When I tested the code on my computer it worked fine.  I tried to debug the plugin by throwing some errors but  in the end I couldn’t figure out what was going on.

The plugin was quite complex, it retrieved some data, then called a report on reporting services and then filed those reports into SharePoint.  The problem I had was it wasn’t working and I didn’t know at what stage it was having trouble.

so I decided to remote debug the plugin.  I have read about how to do it but have never actually needed to because most of the plugins I have deployed are fairly straight forward.

so I searched CRM 2011 remote debugging and amusing the page I found was one I had written!

Actually the first page is an excellent step by step guide a bit similar to this one, you can read that here

The second page was mine which has some good links to articles and videos which you can read here

I will talk you through some of the process.  Basically you first need to download the remote debugger wizard and install it on the server where you are going to debug.

download the remote debugger wizard, which you need to setup on the server, click the link below

Microsoft Visual Studio 2010 Remote Debugger

once you have installed it on the server, I chose not to set it up as a service which means when I want to remote debug I have to log onto the server and click the application, no problemo

This is a good page from Microsoft which list details about setting up the remote debugger.

What you need to do then is build your plugin and then copy the DLL and pdb file onto the server in the directory (or something similar)

C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly

You need the dll and pdb file because it’s the pdb file (symbol!) which actually helps you with the remote debugging.

You now need to open the plugin registration tool, select the DLL and choose to deploy the plugin to disk.  You cannot remote debug if you don’t deploy to disk.  I would also say I would recommend you only deploy plugins to disk when you want to remote debug them, other times always put them in the database.  If you want to read why go here which explains why.

Once you have deployed the workflow you then need to start the remote debugger.  If you are running on Windows 7 then make sure you start the remote debugger as an administrator

once that is up and running (and firewalls set if you need to).  You then go to your machine open visual studio, start up the plugin project.

Go to Debug/Attach to Process

you then need to put in the qualifier, which you can get by going to server, going to the Remote Debugging Monitor (which you need to start if you haven’t already) and then go to tools/options and this will give you something like


you copy this and put it in the qualifer section on the attach to process.  Once you have done this it will then show all the processes you can attach to on the server, you want to choose the W3wp.exe.

now your CRM instance and do what ever you need to do to kick off the plugin and you should then magically drop into your code on your computer.  One word of warning you will need to put in a breakpoint.

Also if it doesn’t catch then basically restart the server, restart the debugging monitor and try it again.

I would also like to warn people that if you are debugging the plugin then you might cause the CRM instance to stop working whilst everyone waits for you to debug the plugin.  When I was stepping through some code it stopped everyone using the system!!!

Make sure you stop debugging when you leave work because it might cause people not to be able to use CRM for quite a long time.

10 thoughts on “CRM 2011 – how to set up Remote debugging for plugins

  1. soso September 13, 2011 / 7:27 pm

    You cannot remote debug if you don’t deploy to disk

    i disagree. It is possible to debug a database deployed plug-in. The compiled plug-in assembly’s .pdb file must be copied to the server’s \Server\bin\assembly folder and IIS must then be restarted. After debugging has been completed, you must remove the .pdb file and reset IIS to prevent the w3wp.exe process from consuming additional memory.


    • Hosk September 13, 2011 / 8:29 pm

      very interesting. I have to admit I only assumed you couldn’t remote debug without saving to disk because I thought that’s what the documentation said.

      excellent tip, thanks for the comment


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s