
Signature
James Rosenfeld
QA Engineer
Countrywide Financial
NOTE: Any opinions expressed are my own and do not reflect the opinions of
my employer.
Hi James,
> Lets say I have an assembly, utility.dll, that I want to register as a COM
> component. I use regasm.exe to register the assembly as a COM component,
[quoted text clipped - 7 lines]
> CoCreateInstance("Utility.MyClass"), which version of the assembly does
> interop use?
1.1.0.0
> Assume I now register/install 1.2.0.0 - which version do I get from
> CoCreateInstance("Utility.MyClass")?
1.2.0.0
> Assume that I discover a bug in 1.2.0.0 and I register/install 1.1.0.0
> again. Which version do I get now?
1.1.0.0
> Sorry if that's a little confusing...basically, I'm trying to see if interop
> will use the last installed version or the "newest" version when an instance
> is created from COM (since you can't specify a version to use...right?).
It will use the last version you have registered with COM.
Robert
James Rosenfeld - 12 Nov 2005 18:30 GMT
> It will use the last version you have registered with COM.
Hmm...
Consider this excerpt from the MSDN doc on regasm.exe:
============
When you register an assembly for use by COM, Regasm.exe adds entries to the
registry on the local computer. More specifically, it creates
version-dependent registry keys that allow multiple versions of the same
assembly to run side by side on a computer. The first time an assembly is
registered, one top-level key is created for the assembly and a unique subkey
is created for the specific version. Each time you register a new version of
the assembly, Regasm.exe creates a subkey for the new version.
For example, consider a scenario where you register the managed component,
myComp.dll, version 1.0.0.0 for use by COM. Later, you register myComp.dll,
version 2.0.0.0. You determine that all COM client applications on the
computer are using myComp.dll version 2.0.0.0 and you decide to unregister
myComponent.dll version 1.0.0.0. This registry scheme allows you to
unregister myComp.dll version 1.0.0.0 because only the version 1.0.0.0 subkey
is removed.
============
If COM is only going to get an instance of the last registered version, what
is the point of keeping multiple versions in the registry?
James