为什么我的程序集在“添加引用”中不可见.Net”什么时候安装到GAC?
有一个关于 GAC 的简单问题
我创建了一个程序集 Awesome.DLL。对其进行签名,然后将其安装到 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
我的问题:
在 C:\Windows\Assembly
或任何子文件夹中找不到 Awesome.DLL。虽然在 C:\WINDOWS\Microsoft.NET\ assembly\GAC_MSIL\
中找到了它,但我想正因为如此,我无法从“添加引用”中看到 Awesome.DLL > 。网。
为什么它不安装到C:\Windows\Assembly\
?我怎样才能指向那个位置呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的程序集安装到
C:\WINDOWS\Microsoft.NET\Assembly\
而不是C:\Windows\Assembly\
,因为它是 .Net 4.0 程序集,而 . Net Framework 4.0 版在该位置有一个新的单独的 GAC。位于C:\Windows\Assembly\
的 GAC 仅包含 .Net 2.0 - 3.5 程序集。 (请参阅.NET 4.0 有一个新的 GAC,为什么? )。在 Visual Studios“添加引用 -> .Net”中找到的程序集列表。对话框不仅仅是在 GAC 中找到的程序集列表(请注意,该列表中的大多数条目在 GAC 中也找不到)。
有关如何将程序集添加到此列表的信息,请参阅以下文章(特别是“在添加引用对话框中显示程序集”部分):
请注意,对于不同版本的 Visual Studio,用于此操作的注册表项有所不同。
Your assembly is installed to
C:\WINDOWS\Microsoft.NET\assembly\
instead ofC:\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 atC:\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):
Note that the registry key used for this is different for different versions of Visual Studio.
我创建了一个完全免费的工具,它将帮助您实现目标。 Muse VSReferences 将允许您添加全局程序集缓存引用从“添加 GAC 参考”菜单项添加到项目。
希望这有帮助。
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.
在 vs2010 项目菜单下检查您的项目属性:
我看到这个项目是“.NET Framework 4 Client Profile”,程序集是“.NET 4 Fraemwork”。
解决方案 :
将项目更改为“.NET Framework 4”配置文件
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