none
Assembly.Load(byte[] rawAssembly, byte[] rawSymbolStore) does not load the expected symbol file RRS feed

  • Question

  • I have one .NET ClassLibrary with a dll file and pdb file in "/bin/x64/Debug." I am trying to load the dll and its symbols into another application while it is running using...

        Assembly.Load(File.ReadAllBytes(dllInBinPathString), FileReadAllBytes(pdbInBinPathString))

    However when the dll is loaded the Modules window indicates that it is using the pdb file located in the obj folder. Is there a way to load the symbols from the bin folder?
    Friday, January 4, 2019 5:24 PM

All replies

  • Does it look better if you delete the PDB file from obj subfolder using File.Delete before Assembly.Load?

    Friday, January 4, 2019 7:24 PM
  • If i delete the PDB file from the obj subfolder before Assembly.Load then the Symbol File in the modules window shows <assembly-name> (dynamic). So it does NOT explicitly point to pdbInBinPathString that I mentioned in the example. Is this okay? The goal here is to rebuild the project that outputs the assembly while the application that loaded it is still running. I cannot do that if the application that loaded the dll is using the pdb file in the obj folder. 

    Friday, January 4, 2019 9:21 PM
  • Hi Doug Tait,

    Thank you for posting here.

    Further to your issue, we could load the symbols from the bin folder by the following method.

    Here is a simple code example.

    class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                string dllInBinPathString = "ClassLibrary1.dll";
    
                string pdbInBinPathString = "ClassLibrary1.pdb";
    
                Assembly.Load(File.ReadAllBytes(dllInBinPathString),File.ReadAllBytes(pdbInBinPathString));
    
                Console.WriteLine(Path.GetFullPath(dllInBinPathString));
    
                Console.WriteLine(Path.GetFullPath(pdbInBinPathString));
    
                Console.ReadKey();
    
            }
    
    }

    Test Result: 

    If you have any other concerns, don’t hesitate to contact me.

    Best regards,

    Jack



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 7, 2019 9:37 AM
    Moderator
  • Hi Doug Tait,

    Thank you for posting here.

    Further to your issue, we could load the symbols from the bin folder by the following method.

    Here is a simple code example.

    class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                string dllInBinPathString = "ClassLibrary1.dll";
    
                string pdbInBinPathString = "ClassLibrary1.pdb";
    
                Assembly.Load(File.ReadAllBytes(dllInBinPathString),File.ReadAllBytes(pdbInBinPathString));
    
                Console.WriteLine(Path.GetFullPath(dllInBinPathString));
    
                Console.WriteLine(Path.GetFullPath(pdbInBinPathString));
    
                Console.ReadKey();
    
            }
    
    }

    Test Result: 

    If you have any other concerns, don’t hesitate to contact me.

    Best regards,

    Jack


     This does not correctly reflect the same scenario I am facing. The Assembly that is calling AssemblylLoad is NOT running out of the same folder as the DLLs that it is loading. 
    Monday, January 7, 2019 6:34 PM
  • Hi Doug Tait,

    According to your issue, I’d like to confirm if you add the ClassLibrary.dll file as a reference? 

    And could you provide more details so that we can give more suitable support.

    We look forward to your reply.

    Best regards,
    Jack 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, January 8, 2019 9:47 AM
    Moderator
  • Jack,

    The ClassLibrary.dll file is not added as a reference however the Project that outputs the dll does reference some of the same assemblies as the application that is loading ClassLibrary.dll. I'm not sure if that is relevant but I though I would mention it.

    Doug

    Wednesday, January 9, 2019 4:08 PM
  • Hi Doug,

    Thanks for feedback.

    I have reproduced your problem, I suggest that you could see the following link to understand the symbol file.

    https://docs.microsoft.com/en-us/windows/desktop/debug/symbol-files

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 29, 2019 7:35 AM
    Moderator