Do I need to force the GAC to reload an assembly?

2019-08-16 05:50发布

问题:

I've added types to my .NET classes that I'm using for COM interop. To get it to work with my VB6 application, I unregistered the DLL and re-registered it (using regasm). I then uninstalled and reinstalled it to the GAC (using gacutil).

The types are showing up in the VB6 object explorer, but when I run the application in the VB6 IDE, it breaks on the line that instantiates the new types with the error: Automation Errror - The System cannot find the file specified.

I thought this odd since I had already updated the GAC, so I uninstalled the dll from the GAC and got the exact same error, which seems to indicate that the older version of the dll is already in memory and needs to be "reloaded" so that the newer DLL is in memory. Is this possible, and if so, what do I need to do?

回答1:

I suspect that regasm.exe is adding COM entries for your objects and pointing them to teh location of the assembly before it was GAC'd. Normally that shouldn't make a difference as the GAC will win in all cases. But there could be a difference for COM interop.

Try digging through the registry and see where the COM entries are pointing to for your COM interfaces and make sure your assembly exists at that location.



回答2:

Try saving your VB6 project, closing the IDE and re-opening your project. That worked for me in this situation.