Debugging · Dynamics CRM 2011 · Visual Studio

Remote Debugging CRM 2011 Plugin

I have had much difficulties configuring Remote Debugging for debugging CRM 2011 Plugin Assembly, so I thought I should share it with everyone. Special thanks to Denifia for advice.

This is my setup:

  1. CRM Server: CRM 2011 Server running on Windows Server 2008 R2 Enterprise with Visual Studio 2010 Remote Debugger installed
  2. Dev Box: Visual Studio 2010 running on Windows 7 Enterprise
  3. CRM Server and Dev Box are on different domains

Without further ado, here are the steps:

Enable Remote Debugging Cross Domains

First of all we have to make sure both security policies on CRM Server and Dev Box are properly configured.

To do this simply:

  1. Open Local Security Policy on Administrator Tools.
  2. Then under Security Settings open Local Policies folder.
  3. Then select Security Options
  4. Then in Policy column find Network access: sharing and security model for local accounts and double-click it
  5. Then make sure it is set to Classic – local users authenticate as themselves
  6. Click OK

Create Identical Local Users on CRM Server and Dev Box

They have to have same username and password, this is important. For simplicity I use ‘debug’ and ‘password’.

Also, they need to be in Administrators group in both CRM Server and Dev Box.

Read more about Remote Debugging Across Domains on MSDN here.

Open TCP port 135

I only needed to do this on my Dev Box, but you may need to do it on the CRM Server as well.

To do this:

  1. Open Windows Firewall in Control Panel
  2. Click Advanced Settings
  3. Click Inbound Rules
  4. Create New Rule to allow inbound traffic for TCP port 135.

Run Visual Studio Remote Debugging Monitor on CRM Server as local user

Use runas command:


runas /profile /user:debug "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe"

In the Visual Studio Remote Debugging Monitor click on Tools and click Options. Copy the Server name as you will use it as Qualifier when you attach to process.

Run Visual Studio on Dev Box as local user

Use runas command:


runas /profile /user:debug "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

Copy Plugins.pdb to CRM Server

Copy Plugins.pdb file to CRM Server assembly folder, normally will be in: “C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly\”. If you registered your plugin to disk, don’t forget Plugins.dll.

Attach to Process

In Visual Studio 2010 click Debug and click Attach to process. Then with Transport = Default, paste the Server name to Qualifier. Processes should start appearing on the Available Processes list (Tick Show processes from all users if you need to), otherwise click Refresh.

If you registered your plugin as Sandbox, attach to Microsoft.CRM.Sandbox.WorkerProcess. Trigger the event for the plugin, and voila, you are happily debugging.

Cheers – Sy

Advertisements

11 thoughts on “Remote Debugging CRM 2011 Plugin

  1. I am trying to debug using remote debugger in 2011, but it is not working. I have VS2010 on local and CRM server runs on the another box. Both are in same domain. I can open the remote monitor and attach to the process w3wp.exe and it is loading the symbol. My pdb is in the bin/assembly folder. But when I trigger an action in the CRM UI, the plugin works, but never hits the breakpoint. No errors. Nothing in event viewer on the CRM server.

    Plugin is registered with Database option. I read about CRM app pool account needing the permission to debug, but can’t find steps how to do it. Any suggestions?

    1. Hi TJ,

      Is your plugin registered as sandbox? If so, you will have to attach to sandbox worker process instead. Also, click on show processes from all users to see if there’s any duplicate processes.

      Cheers,
      Sy

  2. The CRM app pool user wasn’t part of the local admin group. Once I added in the group, the debugging started to work. It hit my breakpoint and I can step through. CRM server runs on Windows 2008 R2 standard and I dont see Debugger Users under local users and groups in mmc.

    Thanks.

  3. Glad you worked it out. I think I did have a problem with adding to Debugger Users but not hitting the breakpoints. Then I just resorted to adding to Administrators.

    Cheers,
    Sy

  4. The Debugger Users group should be created automatically when you install Visual Studio. Although I have read that this may have been removed on new versions. I will update my blog accordingly.

  5. I only have VS remote debugger installed on the CRM server(win 2008 R2 standard), not the VS 2010. This could be the reason why there is no Debugger users group on the CRM server.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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