Solved

Global Assembly Cache

Posted on 2004-03-21
3
348 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

695 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