Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2005

Tip: Looking for answers? Try searching our database.

Multiple assembly versions and COM interop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Rosenfeld - 12 Nov 2005 01:47 GMT
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

Signature

James Rosenfeld
QA Engineer
Countrywide Financial

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

Robert Jordan - 12 Nov 2005 02:54 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.