views:

414

answers:

2

I have a desktop application I'm developing with Visual Studio where I need to update a small part of the app on a more frequent basis. To avoid the inconvenience of deploying a new installer every time, I split the more frequently updated support functions into a separate project and compiled it as a DLL. The desktop app now loads this DLL at runtime with reflection and then instantiates the object inside it based on a shared DLL with an interface definition, like this:

Assembly a = Assembly.LoadFrom(supportDLLPath);
ISupportModuleInterface obj = (ISupportModuleInterface)a.CreateInstance("SupportCode.SupportObject");
if (obj != null)
{
    obj.OnTransferProgress += new FileTransferProgressHandler(obj_OnTransferProgress);
    obj.OnTransferComplete += new EventHandler(uploader_OnTransferComplete);
    obj.DoWork(packagePath)
}

It works fine most of the time, but I need to debug an issue with it and I can't reliably get the Visual Studio debugger to step into it. Sometimes when pressing F11 through the code, such as when stepping into DoWork, it will automatically locate the source code for the DLL on my system and display it. However, when an event is fired, Visual Studio just displays the [External Code] marker in the Call Stack and I can't navigate inside the code in the support project.

Does anyone have any ideas on how to fix this so I can properly debug the support project? Thank you!

A: 

Can you step into disassembly? If so from what I remember, it will give you a path to where the source code was when pdb was created. I had to do this to debug NHibernate and had to place the source code on the exact path where it was when 'pdb' file was created. After that I could step into source code with no problems.

epitka
Unfortunately, no. I right-clicked on [External Code] and Go To Disassembly is disabled. I tried adding the location where the .pdb file is under Options->Debugging->Symbols and it still doesn't recognize anything from the DLL.
jasonh
+1  A: 

Is the assembly listed in the "Modules" window (Debug -> Windows -> Modules, or press "Ctrl-D, M"), and is it listed as "Symbols Loaded.", with the symbols loaded from the location that you expect? (You can force it to load symbols by right clicking and selecting "Load symbols...". If it cant find a symbol file that matches it will prompt you with an "Open..." dialog).

Also check in this window to make sure that the module isnt loaded twice, and that the version / timestamp / location of the assembly is what you would expect it to be.

Finally check to see if "Just My Code" is chcked under "Tools -> Options -> Debugging", and see if unchecking it makes a difference.

Kragen
Success! It picked it up after pointing it to the PDB file and restarting the project.
jasonh