* WHY * doesnโ€™t Visual Studio allow you to reference the assembly in the GAC?

Several questions were asked that answered HOW or, more precisely, how to get around this Visual Studio limitation:

Missing GAC assembly in the Add Link dialog box How can I link to a dll in the GAC from Visual Studio?

MSDN documentation though says:

You cannot add links from the Global Assembly Cache (GAC) because it is strictly part of the runtime environment.

So it seems that the Visual Studio team did this on purpose. Maybe they did it so you don't hurt yourself? What best practice would I break by referencing a build in the GAC using a VS extension like this? Did I miss something?

Just double check the community, evaluate your thoughts.

+4
source share
3 answers

With Sharp Develop (which is an open source IDE for .NET) you can add GAC links, and .NET 4 you can add GAC links. You definitely won't hurt yourself by adding GAC links. I have no negative reviews from developers using it.

Soon, this extension will have more sexual functions.

+3
source

This does not really stop you from doing this. In particular, for .NET 4.0, you can use the Browse tab to access c: \ windows \ microsoft.net \ assembly. A shell extension handler that stops you from accessing GAC.NET 2.0 through shell dialogs is not included in 4.0

But yes, this is a really bad idea. The GAC is detailed deployment information; you cannot assume that the contents of your GAC will match those on another computer. Only a reference build can give you a stable set of type definitions that don't change when, say, you get a security update through Windows Update.

This is even more relevant for .NET 4.0. Its referenced assemblies are special. They are no longer a copy of the assemblies that you can find in the GAC or in c: \ windows \ microsoft.net. They contain only metadata, not IL. This allows Microsoft to deploy updates that change public types in assemblies. Something bad in .NET 2.0 packages (e.g. WaitHandle.WaitOne (int)).

+3
source

Because the GAC may have more than one version of this Assembly, so it will be very complex very quickly. It is easier to require that a copy of the version you want to link to be in a regular folder.

(In most cases, you should not use the GAC, since it is as painful as the Register was on COM days.)

+1
source

All Articles