Solved

Global Assembly Cache

Posted on 2004-03-21
3
347 Views
Last Modified: 2012-05-04
Hi,

I have created 2 versions of a dll (mydll.dll) and I have registered into the Global Assembly Cache. I registered this using the tool mscorcfg.msc. I created 2 console applications say (A & B). I want Application A to call one version of mydll and the Application B to call the second version. Is there a way to do this programmatically and not using any tool like mscorcfg.msc?


Usha
0
Comment
Question by:ushakv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
eric_duncan earned 20 total points
ID: 10691897
Sure. In fact, you didn't even have to register your .dlls in the GAC to manage the two versions, simply assigning them a strong name works as well.

To start with, in order to add a reference to the assemblies you will need to have them both installed somewhere on your machine so you can browse to them in the Add References... dialog box. Even though you've placed them in the GAC, Microsoft doesn't give you a good way to get to them.

Next, add a reference to the specific version of the assembly you need in each application via the Add References... dialog box. Even though you'll be browsing to a directory in the local filesystem, the IDE is smart enough to figure out that you also have the same version of the .dll in the GAC so it will set the application up to use that file. To verify this, you can view the properties of the reference in the IDE and check that the Copy Local property is set to 'False'.

Since each assembly has a strong name, .Net will automatically bind to the specific version of the assembly. So if you later install a newer version of the assembly in the GAC, .Net will still continue to use the older versions until you either recompile with the new reference or redirect the reference using the machine.config or application.config files.

To make it easier to add references to the assemblies in the future, you can also look at this link that tells you how to set up the IDE so that your assemblies will show up in the components list of the Add References dialog so you don't have to browse for them every time.

http://support.microsoft.com/default.aspx?scid=kb;en-us;306149

You can also check these links out that discuss versioning and the GAC in more detail:

http://www.dotnetextreme.com/articles/versioning2.asp

http://weblogs.asp.net/rpooley/archive/2003/11/06/36138.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconside-by-sideexecutionoverview.asp

I hope that this helps.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question