How to see your GAC-assemblies in the "add reference" dialog

IMHO it's a pity that you don't see every GAC-installed assembly when you do "add reference" from Visual Studio, and I couldn't find much information in the VS documentation about this. So I Googled around a bit and found these ways (I haven't tried them yet):

  • Put a copy of your assembly in C:\WINNT\Microsoft.NET\Framework\v1.0.3705  or  C:\WINNT\Microsoft.NET\Framework\v1.1.4322 or wherever your framework is installed
  • Add a new registry key under one of the following registry paths with a default value that points at the location of your assemblies.:
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders  (I found WSE, NUnit and the Primary Interop Assemblies here).
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.1\AssemblyFolders (this is for VS.NET 2003 I think)
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\AssemblyFolders (this is for VS.NET 2002 I think)
  • Put a copy of the assembly in the directory C:\Program Files\Microsoft Visual Studio\Common7\IDE\PublicAssemblies or, if you got VS.NET 2003, in the C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\PublicAssemblies directory.

I'm not sure yet, what the best choice is. According to the readme-file in the PublicAssemblies-directory:

"The PublicAssemblies folder is designed to contain managed assemblies that run within the development environment and are typically called from macros, add-ins, and other user code. The assemblies in this directory are displayed in the Project Add References dialog box and the Object Browser's Component Selector dialog box. For example, COM interoperability wrappers for automation object models (e.g. vslangproj.dll) should be installed in the PublicAssemblies folder."

I'll try the different options and see what happens, but I think I prefer to put my assemblies into a directory of my own, like C:\MyGACFiles\ and then add a "MyGACFiles" key to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders section.

Anyone with good experience with this? Is it changed in Whidbey so that you get a list of GAC-ed assemblies in the "add reference" dialog?



    VS.NET 2002 & 2003 will pick up your assembly.

  • That's funny ... I just taught a quick lesson on how to create developer-oriented setup packages and spent 10 minutes looking how to do this ... you must have been typing this at the same time i was teaching it ... weird :)

  • Matt: I've not seen that key before (using "assemblies" as sub-key).

    Adam: The world is a weird place... ;)

    Robert: Good idea to add the version data to the registry key. Thanks.

  • Robert, I agree about having a good structure in the registry, but can give some more detail about "the proper way to use the registry", maybe with links to authoritative sources?

    Not just this:

    "The point of all this is not to tell you that my way is the only right way of doing things, or that I think I'm a genius or the smartest guy in the world for coming up with it."

  • Do a search on MSDN for "AssemblyFolders" and see what you got... not much I can tell you. There is a small article by Izzy Gryko from the Visual Studio Team about how to "support multiple versions of the same component on a single machine in Visual Studio .NET 2003". It has a few good parts, but it doesn't say much about "the proper way" to use the registry.

  • Your solution may work in a case that you created some assembly and registered in in GAC. I needed to use an assembly that was installed in the GAC, but I had no idea where it's DLL file reside. Fortunately, I had a sample project with these references. So I opened the project file in a text editor and copied the required references. It seems to be easier than dealing with registry.



Comments have been disabled for this content.