HighTechTalks DotNet Forums  

Multiple assembly versions and COM interop

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Multiple assembly versions and COM interop in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
James Rosenfeld
 
Posts: n/a

Default Multiple assembly versions and COM interop - 11-11-2005 , 08:47 PM






Greetings,

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,
then use gacutil.exe to install it in the GAC. At this point, I should be
able to create an instance of the component using
CoCreateInstance("Utility.MyClass").

Assume the first time I do this, utility.dll has a version of 1.0.0.0. Now,
I register/install version 1.1.0.0, so I now have both 1.0.0.0 and 1.1.0.0
registered and installed in the GAC. When I use
CoCreateInstance("Utility.MyClass"), which version of the assembly does
interop use?

Assume I now register/install 1.2.0.0 - which version do I get from
CoCreateInstance("Utility.MyClass")?

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?

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?).

Thanks in advance,

James

--
James Rosenfeld
QA Engineer
Countrywide Financial

NOTE: Any opinions expressed are my own and do not reflect the opinions of
my employer.


Reply With Quote
  #2  
Old   
Robert Jordan
 
Posts: n/a

Default Re: Multiple assembly versions and COM interop - 11-11-2005 , 09:54 PM






Hi James,

Quote:
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,
then use gacutil.exe to install it in the GAC. At this point, I should be
able to create an instance of the component using
CoCreateInstance("Utility.MyClass").

Assume the first time I do this, utility.dll has a version of 1.0.0.0. Now,
I register/install version 1.1.0.0, so I now have both 1.0.0.0 and 1.1.0.0
registered and installed in the GAC. When I use
CoCreateInstance("Utility.MyClass"), which version of the assembly does
interop use?
1.1.0.0

Quote:
Assume I now register/install 1.2.0.0 - which version do I get from
CoCreateInstance("Utility.MyClass")?
1.2.0.0

Quote:
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

Quote:
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


Reply With Quote
  #3  
Old   
James Rosenfeld
 
Posts: n/a

Default Re: Multiple assembly versions and COM interop - 11-12-2005 , 01:30 PM



"Robert Jordan" wrote:
Quote:
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


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.