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:
- CRM Server: CRM 2011 Server running on Windows Server 2008 R2 Enterprise with Visual Studio 2010 Remote Debugger installed
- Dev Box: Visual Studio 2010 running on Windows 7 Enterprise
- 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:
- Open Local Security Policy on Administrator Tools.
- Then under Security Settings open Local Policies folder.
- Then select Security Options
- Then in Policy column find Network access: sharing and security model for local accounts and double-click it
- Then make sure it is set to Classic – local users authenticate as themselves
- 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:
- Open Windows Firewall in Control Panel
- Click Advanced Settings
- Click Inbound Rules
- 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