Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my assembly not visible in "Add Reference > .Net" when installed to the GAC?

Just have a quick question about the GAC
I created an assembly Awesome.DLL. Had it signed, then installed into the GAC:

C:\MyApps\Awesome\Awesome\Awesome\bin\Release>sn -k Awesome.snk
Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1 
Copyright (c) Microsoft Corporation.  All rights reserved.

Key pair written to Awesome.snk

C:\MyApps\Awesome\Awesome\Awesome\bin\Release>gacutil /i Awesome.dll 
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1 
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

C:\MyApps\Awesome\Awesome\Awesome\bin\Release>gacutil /l Awesome.dll 
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1 
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:

Number of items = 0

My problem:

Awesome.DLL is not found in C:\Windows\Assembly or any of the sub folders. It is found, though in C:\WINDOWS\Microsoft.NET\assembly\GAC_MSIL\ I guess because of this, I am not able to see Awesome.DLL from Add Reference > .Net.

Why does it not install to C:\Windows\Assembly\? How can i point to that location instead?

like image 399
John Avatar asked Feb 25 '11 03:02

John


2 Answers

Your assembly is installed to C:\WINDOWS\Microsoft.NET\assembly\ instead of C:\Windows\Assembly\ because it is a .Net 4.0 assembly and the .Net framework version 4.0 has a new separate GAC in that location. The GAC located at C:\Windows\Assembly\ contains only .Net 2.0 - 3.5 assemblies. (see .NET 4.0 has a new GAC, why?).

The list of assemblies found in Visual Studios "Add Reference -> .Net." dialog is not simply a list of assemblies found in the GAC (notice that most of the entries in that list aren't found in the GAC either).

For information on how to add your assembly to this list see the following article (specifically the "To display an assembly in the Add Reference dialog box" section):

  • How to: Add or Remove References in Visual Studio

Note that the registry key used for this is different for different versions of Visual Studio.

like image 154
Justin Avatar answered Nov 13 '22 13:11

Justin


I've created a tool which is completely free, that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.

Hope this helps.

like image 27
BALKANGraph Avatar answered Nov 13 '22 12:11

BALKANGraph