VS won’t reference assemblies in GAC

This is by design.

 The reason is that assemblies installed in YOUR development machine is not necessary the same as what your application requires. Let VS to reference assemblies installed in your development machine is clearly not the right thing.

An analogy to unmanaged developement. VS search %INCLUDE % for header files, and %LIB% for lib files. It does not search %PATH% for those things.

Same applies to managed development. For managed assemblies, there are no header or lib files. Everything is contained in the assembly itself. Adding a reference to your VS really means looking for those metadatas.

Use the unmanaged development analogy, VS won't look at GAC for it.

Yes, maybe we do need headers for managed assemblies.

Comments (3)

  1. This is one of the "features" I hate the most. A) Pulling the assemblies from the GAC is an expected behavior.

    B) There is little or no documentation, as a component vendor, on how to make your assembly show up.

    C) You HAVE to use an installer program to get the assembly to show up in VS, due to the need for registry manipulation.

    D) If you have multiple assemblies installed in the folder, they will ALL show up in VS.NET, which is also not an expected behavior.

    This is confusing to me, because if VS.NET has a "CopyLocal" option for assemblies, then why not pull from the GAC?

    I have a detailed write-up of some solutions for current GAC-related issues here: http://weblogs.asp.net/rmclaws/archive/2003/10/16/32298.aspx

  2. The reason is, when you build your application, you want your dependencies to be deterministic. You can’t guarantee that when VS starts to reference assemblies in your GAC. Say you have v1 in GAC, and I have v2 in GAC. Now you and I build the same solution. Your app will depend on v1, while my app will depend on v2. This is clearly wrong.

    I agree that the documentation is weak. And reg key approach sucks. All these need to be improved. But it does not mean VS should reference assemblies in your development machine.

  3. If you want to add assemblies to the ‘Add Reference’ dialog in Visual Studio .NET, and your assemblies don’t already have homes, use Andrew Troelsen’s method. If your assemblies already have homes, though, use this method to add them wherever…

Skip to main content