locked
Debug Plugin Not Working RRS feed

  • Question

  • I installed CRM 2011 on a server along with VS2010 to develop plugin. I followed http://msdn.microsoft.com/en-us/library/gg328574.aspx to debug plugins but for some reason it is not working. Here is my setup:

    * CRM 2011 on premise + Visual Studio on same server
    * Plugin's isolation mode is "None" and the assembly is stored in the database
    * Plugin step is set as "Post-operation (CRM 2011 Only)", synchronous and deployed on the server
    * After updating the plugin through the pluginRegistrationTool I copy the pdb file into server\bin\assembly and do an iisreset

    First I did attach to the 3 w3wp.exe processes. However, I always get the "The breakpoint will not currently be hit. No symbols have been loaded for this document". I also tried with just adding "System.Diagnostics.Debugger.Launch();" in my source code. The debugger indeed gets started but the plugin just executes (I know because it blows up after the breakpoint and after the system.diagnostics.debugger.launch).

    What am I doing wrong and how do I get this to work?

    Two notes that might be relevant:

    * I use ILMerge. First I make a copy of the dll then merge the copy and name the output the same as the original dll.
    * The w3wp.exe runs as NETWORK SERVICE but I am logged in with the credentials as the deployment administrator defined in the Deployment Manager.

    Saturday, October 6, 2012 3:38 AM

Answers

  • I got this to work now. What I did is creating a temporary merged file and then copy it back to the original name. So the post build now looks like this:

    ILMerge plugin.dll one.dll xrm.dll /keyfile:key.snk /out:pluginMerged.dll /closed //targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
    copy pluginMerged.dll plugin.dll
    copy pluginMerged.pdb plugin.pdb

    Now I can set a breakpoint, attache to the process and the breakpoint gets triggered. The only drawback is that the PluginRegistrationTool picks up the merged name, i.e. pluginMerged. This means I need to deregister everything and register it again. It's also a big confusing because the filename does not match the assembly name. But it works!!

    Saturday, October 6, 2012 7:42 AM
  • I finally found a workaround for the last issue, i.e. keeping the assembly name. The trick is to send the output to a different directory and then copying it back. So that looks like this:

    ILMerge plugin.dll one.dll xrm.dll /keyfile:key.snk /out:./temp/plugin.dll /closed /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
    copy ./temp/plugin.dll ./plugin.dll
    copy ./temp/plugin.pdb ./plugin.pdb

    With that I still have the same assembly name AND my breakpoints get triggered.

    • Marked as answer by hfaun Sunday, October 7, 2012 5:10 AM
    Sunday, October 7, 2012 5:10 AM

All replies

  • I did build a new simple plugin and once left it alone and then did an ILMerge with the a couple of other dlls. In both cases I got the "The breakpoint will not currently be hit. No symbols have been loaded for this document". However, in the first case it would still break at the breakpoint. When I did an ILMerge then the breakpoint would not get triggered. So the issue is somewhere with ILMerge.

    In principle, my post build looks like this:

    copy plugin.dll temp.dll
    ILMerge temp.dll one.dll xrm.dll /keyfile:key.snk /out:plugin.dll /closed //targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"

    The pdb files also seem to be merged. So why is this not working, i.e. why is the breakpoint not being triggered?

    Btw, I also tried to do a copy plugin.pdb temp.pdb but then when I do an ILMerge it always says access denied to plugin.pdb. I don't quite understand why that is. Maybe ILMerge does not look at the filename of temp.dll to determine the appropriate pdb file but the content and so associates temp.dll with plugin.pdb?

    Saturday, October 6, 2012 6:07 AM
  • Based on what I said before I did not copy plugin.dll to a temporary file but instead just created a new output file pluginMerged.dll So now my post build looks like this:

    ILMerge plugin.dll one.dll xrm.dll /keyfile:key.snk /out:pluginMerged.dll /closed //targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"

    Of course now I had to deregister the old plugin and re-register it with the new name. After that change I can now not only trigger the debugger with System.Diagnostics.Debugger.Launch() but it indeed stops and let's me debug the project. I actually don't even have to load a new instance but can use my plugin project. So that's a good first step. However, what I really want is setting a breakpoint, attached to w3wp.exe. When I do this the breakpoint does not get triggered, though. I guess it's because my dll is pluginMerged.dll but the project's output is plugin.dll.

    Is there a way to get this working with breakpoints?

    Saturday, October 6, 2012 7:06 AM
  • I got this to work now. What I did is creating a temporary merged file and then copy it back to the original name. So the post build now looks like this:

    ILMerge plugin.dll one.dll xrm.dll /keyfile:key.snk /out:pluginMerged.dll /closed //targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
    copy pluginMerged.dll plugin.dll
    copy pluginMerged.pdb plugin.pdb

    Now I can set a breakpoint, attache to the process and the breakpoint gets triggered. The only drawback is that the PluginRegistrationTool picks up the merged name, i.e. pluginMerged. This means I need to deregister everything and register it again. It's also a big confusing because the filename does not match the assembly name. But it works!!

    Saturday, October 6, 2012 7:42 AM
  • I finally found a workaround for the last issue, i.e. keeping the assembly name. The trick is to send the output to a different directory and then copying it back. So that looks like this:

    ILMerge plugin.dll one.dll xrm.dll /keyfile:key.snk /out:./temp/plugin.dll /closed /targetplatform:v4,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
    copy ./temp/plugin.dll ./plugin.dll
    copy ./temp/plugin.pdb ./plugin.pdb

    With that I still have the same assembly name AND my breakpoints get triggered.

    • Marked as answer by hfaun Sunday, October 7, 2012 5:10 AM
    Sunday, October 7, 2012 5:10 AM