How do you debug an assembly loaded through Assembly.Load (byte [])?

I am creating a plugin for a product that loads plugin DLL files using Assembly.Load(byte[]) . All this is very good and good, but that means that I don’t have the usual ways to load debugging symbols to go through my code.

The crazy thing: a few months ago I had the same problem and it was solved - and I was proud of myself! Therefore, I know that this can be done, I just forgot how to do it.

I have some vague recollections of things that I may have tried, but I cannot tease details from my head:

  • .NET Reflector
    • Probably wrong, though, since I clearly remember that I went to the source .cs file.
  • Using IIS Express, not Cassini
    • But this seems like a strange solution to me - the assembly is loaded from a byte array, so the infrastructure knows nothing about where the DLL came from, or what the corresponding PDB might look like if it sees it. This problem must exist in any environment.
  • Manually loading characters through the Modules window
    • Tried this; I get "The xxxxx.pdb character file does not match the module" - because, of course, we are loading from a byte array, and not from the DLL itself.
+6
source share
1 answer

If your assembly is strongly named, you can put it in the GAC. Strongly named assemblies are always loaded from the GAC, even if they are loaded via Assembly.Load(byte[]) . Then just put your characters in C:\Windows\symbols\dll or where ever conveniently. I do this all the time to debug our own product plugin DLL files that are loaded by another application in a similar way.

You can use gacutil to install it in the GAC. Remember to remove it when you finish debugging, or you can run tests against the old version, which you GAC'd and forgot.

+1
source

All Articles