none
How to debug a dynamically loaded assembly. RRS feed

  • Question

  • I have a system that locates and load assemblies at runtime.

    It instantiates classes and invokes methods in them (they conform to an interface) but, even though I have opened the src file I cant set a breakpoint.

    The debugger notes that "no symbols have been loaded for this document".

    Is there a way to have the loaded assembly automnatically find/load debug symbols, or must I manually navigate and try to load the pdb file??

    Thx
    Thursday, February 12, 2009 3:49 PM

Answers

  • Did you try locating your .pdb file in the same folder as the assembly you are loading?  (Not sure if that is feasible or not for your application.)

    Also, the Tools, Options, Debugging, Symbols configuration lets you set locations tp search for .pdb files.  You could also check that out.

    • Marked as answer by Zhi-Xin Ye Wednesday, February 18, 2009 3:06 AM
    Thursday, February 12, 2009 11:44 PM
  • Debug + Other Windows + Modules.  Right click the assembly to find out where it looked to find the .pdb
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Wednesday, February 18, 2009 3:06 AM
    Friday, February 13, 2009 1:51 AM
    Moderator

All replies

  • Did you try locating your .pdb file in the same folder as the assembly you are loading?  (Not sure if that is feasible or not for your application.)

    Also, the Tools, Options, Debugging, Symbols configuration lets you set locations tp search for .pdb files.  You could also check that out.

    • Marked as answer by Zhi-Xin Ye Wednesday, February 18, 2009 3:06 AM
    Thursday, February 12, 2009 11:44 PM
  • Debug + Other Windows + Modules.  Right click the assembly to find out where it looked to find the .pdb
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Wednesday, February 18, 2009 3:06 AM
    Friday, February 13, 2009 1:51 AM
    Moderator
  • Did you try locating your .pdb file in the same folder as the assembly you are loading?  (Not sure if that is feasible or not for your application.)

    Also, the Tools, Options, Debugging, Symbols configuration lets you set locations tp search for .pdb files.  You could also check that out.


    Hi

    This was some time back now, but I'm still wondering about this (I did have work around).

    What if (for arguments sake) both the DLL and the PDB were binary blobs stored in SQL server? I'm seeking some way to load the PDB at runtime (much as one can load an assembly from a binary stream at runtime).

    Is there an API, Win32 call, .Net class that supports this? Just how is a PDB actually loaded?

    Cap'n

     

    Saturday, October 2, 2010 12:09 PM
  • Is this because you are trying to get line numbers?

    I stumbled across this "technique" that might help: http://timstall.dotnetdevelopersjournal.com/getting_file_and_line_numbers_without_deploying_the_pdb_file.htm

     

    Saturday, October 2, 2010 1:47 PM
  • Is this because you are trying to get line numbers?

    I stumbled across this "technique" that might help: http://timstall.dotnetdevelopersjournal.com/getting_file_and_line_numbers_without_deploying_the_pdb_file.htm

     


    No not really that.

    I just want to be able to debug the code in Visual Studio. The .PDB seems to always be assumed to be a disk file, but in my case it isnt, the DLL and PDB are persisted to a non-disk medium.

    Is there an API for loading a PDB?

    I guess I could copy the data to a temp disk file and load it from there, but I'd like to do this automatically in some way.

    Thanks

    Cap'n

     

    Monday, October 11, 2010 11:25 PM
  • byte[] dllBytes = File.ReadAllBytes(dllFilePath)

    byte[] pdbBytes = File.ReadAllBytes(pdbFilePath)

    Assembly assembly = Assembly.Load(data, pdbData);

    Monday, April 20, 2015 2:08 PM