How to debug workflow assemblies and plug-ins in MSCRM 4.0
Remote debugging sounds like the title to a book but it isn't - in truth, I have never used remote debugging because haven't needed to. In MSCRM 3.0 the exceptions bubbled up nicely in workflow and I could do a lot on my own machine. However in MSCRM 4.0, those exceptions don't bubble up nicely :( All you get is something like this:
Beside's adding logging to your assembly (which you should do anyway), what's a dev to do now? You can now debug your plug-in's and custom workflow activities using the remote debugging facility in Visual Studio and that's what I hope to show in the next 9 easy steps!
- On your machine you'll find a folder <system drive>\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger (assuming you installed Visual Studio 2008 to the default location) which contains an x86 folder. Copy that to the MSCRM server and run the msvsmon.exe file.
- Now click Tools -> Permissions and give yourself access to it.
- Now load you plug-in or custom workflow activity (when I refer to plug-in for the rest of the document it means both, unless otherwise stated) using the *cough*annoying*cough* plug-in registration/developer tool.
- Next copy the PDB file for your assembly to the <system drive>\Program Files\Microsoft Dynamics CRM\Server\bin\assembly (assuming you installed MSCRM 4.0 to the default location).
- Now to finish up the MSCRM server side do an IISReset and restart the Async Windows Service.
- Back on your machine now in Visual Studio, set a break point in your code.
- Next click Debug -> Attach to Process. The transport should be Default and the Qualifier should be <domain>\<username running msvsmon.exe on the server>@<Server name>. Note: You can get this from the Tools -> Options in msvsmon.exe. You may need to do some firewall configuration but it should be automated.
- Next select the process to attach to, for an online plug-in, attach the debugger to the w3wp.exe process on the Microsoft Dynamics CRM server. For an offline plug-in, attach the debugger to the Microsoft.Crm.Application.Hoster.exe process. For asynchronous registered plug-ins or custom workflow activity attach to the CrmAsyncService.exe process.
- Now do whatever is needed to trigger your event and watch Visual Studio on your machine do it's magic!




I am a community lead in this group.
Make sure you sign your
Submitted by Anonymous on Mon, 01/11/2010 - 17:37.Make sure you sign your assembly. If it's not signed, this will not work.
Thanks a lot for the
Submitted by CRM User on Thu, 06/25/2009 - 10:59.Pingback
Submitted by Debugging plug-ins in v4.0 (Updated) &laquo; The CRM Gri on Tue, 06/09/2009 - 11:46.[...] just found this article at sadev.co.za on how to debug CRM plug-ins remotely. Possibly related posts: (automatically generated)Prevent [...]
I followed the instructions
Submitted by Szczepan Bury on Wed, 04/15/2009 - 15:59.Make sure you build in debug
Submitted by Robert MacLean on Thu, 04/16/2009 - 12:02.still doesnt work
Submitted by Visitor on Fri, 07/23/2010 - 15:04.still doesnt work
Pingback
Submitted by Brutus Online ยป CRM 4.0 plugin voor dummies on Tue, 04/07/2009 - 00:15.[...] Is debuggen mogelijk en zo ja : hoe? Daar kan ik een heel mooi epistel over schrijven maar dat kunnen anderen [...]
Pingback
Submitted by Attaching Custom workflow activity to a process (Debugging) on Sun, 01/18/2009 - 19:25.[...] etc.... I'm trying to attach my workflow to a process. I followed the steps in the below article http://www.sadev.co.za/node/153 I tried both w3pw.exe and Asuncronouscrm.exe. Below is my code. (I created a workflow activity [...]
Upgrade CRM 3.0 to CRM 4.0
Submitted by Victor on Fri, 02/01/2008 - 02:34.Hello,
I already have CRM 3.0 on my computer and would like to upgrade to CRM 4.0.
Shall I have to run CRM 4.0 setup and then uninstall CRM 3.0? or is there a better way?
Thank you.
Upgrade CRM 3.0 to CRM 4.0
Submitted by Tiaan van Niekerk on Tue, 04/07/2009 - 09:39.Post new comment