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

≯℡__Kan透↙ 提交于 2019-12-05 16:12:33

问题


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?


回答1:


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.




回答2:


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.




回答3:


Check your project properties under vs2010 Project menu: i've seen this were the project is ".NET Framework 4 Client Profile" and the assembly is ".NET 4 Fraemwork". solution : Change the project to ".NET framework 4" profile



来源:https://stackoverflow.com/questions/5113186/why-is-my-assembly-not-visible-in-add-reference-net-when-installed-to-the-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!