in

Platinum Bay

Peace, Love and Visual Studio Team System

.NETicated

Add Reference and the GAC

One common misconception regarding Visual Studio that I run across quite frequently involves the Add Reference dialog and the GAC.

Adding a reference to a Visual Studio project is as simple as right-clicking on the References folder, choosing "Add Reference…", and selecting the reference you wish to add from the dialog box that appears. However, and here is the confusion, assemblies that have been registered in the GAC will not appear in this list. This is because the Add Reference dialog does not enumerate the assemblies installed in the GAC. Rather, it is path-based and uses several registry keys to locate assemblies with which to populate the dialog.

Registry Keys:

The registry keys used by Visual Studio to populate the Add References dialog are:

  • [HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
  • [HKEY_CURRENT_USER]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders

To add your assembly folder, create a sub key with a descriptive name, and set the default REG_SZ value to the folder path. If Visual Studio is open, it must be restarted for the added folder path to be enumerated. Notice that both the Local Machine and Current User registry hives are listed above. You can add assembly folders to either key to scope them if needed.

Example:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MyAssemblies]@="C:\\MyAssemblies"

As a closing note, remember that it is not recommended to install assemblies to the GAC unless they need to be shared among multiple applications running on the system.

Published Sep 02 2008, 09:18 AM by Steve
Filed under:

Comments

September 2, 2008 7:20 AM

If you want to add a reference to an assembly in the GAC, you don't have to go through all that. SharpDev will allow you to add a reference to the assembly from Add Reference.

sharpdevelop.net/.../Default.aspx

 

September 3, 2008 6:07 AM

Pingback from  Dew Drop - September 3, 2008 | Alvin Ashcraft's Morning Dew

 

September 7, 2008 8:04 AM

My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Sara Ford's Tip of the Day #305 shows how to reevaluate expressions in the QuickWatch window . Brad Abrams explains how VS208 Multitargeting

 

September 14, 2008 9:39 PM

Unable to add reference to assemblies in GAC from VS

 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews has been working as a developer for more than 8 years. During this time, he has designed and developed applications in such widely varying areas as trust accounting, medical information management, supply chain management, and retail systems. He has firsthand developer experience with a variety of languages, including Java, VB, and .NET. Most recently, he has been immersed in SharePoint. He is currently employed at RDA Corporation in Philadelphia, PA, as a Software Engineer and a team member in the Architectural Guidance evangelism team. Steve is also an MTCS (x2), ICSOO, and .NET fanatic.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.