Search code examples
c#vb6.net-assemblygacregasm

Does GAC conflict with the Registry for Assembly Loading?


I have a DLL I generate from a C# project. I then register it via regasm so that the library can be used inside several legacy VB scripts.

Recently I created a new project (C# console app) that will reuse certain modular aspects of the original library, and per good programming practice it made sense to add the library to the GAC for reuse by this and any future projects.

I've found that it plays nice at first, but after the server is rebooted, the VB scripts crash and burn, claiming they are unable to create an object of one of the types defined in the library.

The fix involves removing the library from the GAC and re-registering the library via regasm.

  • The libraries in the registry and GAC come from the same physical DLL file - same directory and everything.
  • I've confirmed the existence of registry entries for the library every step of the way, which says regasm did its job.
  • GAC entries only exist when the library is installed, and properly disappear when it is uninstalled. They only ever appear under GAC_MSIL, where, to my knowledge, they should be.

Any ideas why this is happening?

EDIT: I did not read the fine print, haha. On the regasm documentation I just saw this: "Creates a Codebase entry in the registry. The Codebase entry specifies the file path for an assembly that's not installed in the global assembly cache. Don't specify this option if you will subsequently install the assembly that you're registering into the global assembly cache. It is strongly recommended the assemblyFile argument that you specify with the /codebase option be a strong-named assembly." I was using that switch, so I will dig deeper. In the meantime any additional insights are greatly appreciated.


Solution

  • I would guess you didn't renew the GUIDs and/or distinguish the fully qualified type names of the new library and when you installed it with regasm, the old entries in the registry got overwritten. Registering the old library again has overwritten the new library's registry, but as you don't use it through COM that didn't affect it and now the scripts work again.