Solved

Global Assembly Cache

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now