I was having a bit of a nightmare debugging my plugins. The plugin was working in my test case but when I deployed it and tried to run it from CRM, I was getting errors.
I had tried to setup remote debugging which I have done before but this time I was having problems because of some kind of firewall related problems and when I dropped my firewall the remote debugger could talk to my computer but the debugger wasn’t catching.
I then tried to get the profile/debugger working in the plugin registration tool but I kept getting stuck when it asked for a profile location, WHAT THE HELL IS THIS PROFILE.
I tried to google instructions for the profile/debugger but I couldn’t find anything but then out of the blue one of the blogs I follow wrote an article about it and saved the day.
if you want to use the plugin registration tool debug then follow these instructions
so basically you have to install and turn on profiling, then go into CRM, trigger the plugin. This will then download your profile file. Then in the Plugin Registration tool debug the plugin, choose your dll and newly downloaded profile text document, set the debug on your visual studio and attach the process to the plugin registration tool. Now in the Plugin Registration Debug page, click Start Plugin Execution.
Basically the profile you downloaded is probably serialized variables and values which is now loaded into visual studio, allowing you walk through the code with the values you entered into CRM.
The tool is great and you can do it all from your PC.
Now onto the problems I was having. I had set up a plugin to run on the post operation of an entity update.
What seemed to be happening was the main values of the entity were being copied but no related entity information was being created. My code was using one of the related entities in a query.
To get round the problem I used the guid of the entity and retrieved the related entity information and then I could walk through the rest of my code.