How to Debug Plug-Ins in CRM
Sometimes you might get wonder (even frustrated) why the debugger is not hitting the break point in your Plug-In code file.
Below are the Checklist to perform prior to start the debugging of your Plug-in assembly.
- Ensure that your plug-in assembly is signed (See)
- Rebuild the plug-in assembly
- Reset the IIS (i.e. Open command prompt and run ‘iisreset’ command)
- Restart CRM Asynchronous Service on CRM server (Only in case of asynchronous plug-in or Custom workflow )
- Copy the .pdb file and your .dll file to server’s assembly (i.e., ..\Program Files\Microsoft Dynamics CRM\Server\bin\assembly)
- Open the Plug-in Registration Tool (Download)
- Browse the dll from your Plug-Ins projects “bin\debug” folder
- In Plug-in Registration Tool , Choose “Specify the location where assembly should be stored” option as “Disk”
- Register the step
- Register the image(s) if any
- Attach the process by opening the Plug-in project in the Visual Studio and then
- From menu choose “Debug -> Attach to Process…” ( or Click ‘Alt + Ctrl + P’)
- Select w3wp.exe (i.e.,Worker Process), if plug-in is Synchronous
- Select CRMAsyncService.exe, if Plug-in is asynchronous or Custom workflow.
- You are all set by now and put a break point (Click F9) on relevant code line.
In case of Remote Debugger :-
- If your CRM server machine is different from your development machine
- Install “Visual Studio Remote Debugger” (Download) on CRM server machine
- Run it as “Administrator”
- Follow the same steps above except while attaching Process, in the “Attach to Process” window, set “Qualifier” as “CRM server machine”
Debug plug-in in outlook offline mode
- Clean and rebuild the plug-in solution on your machine using visual studio
- Register the plugin on the server
- Synchronize the organization with the outlook
- Go Offline
- Attach the debugger to the process “Microsoft.Crm.Application.Hoster.exe”
- Place a breakpoint in the code.
- Run the scenario
Hope it helps :)