Solved

Global Assembly Cache

Posted on 2004-03-21
3
346 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

790 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