Dot-Net
為什麼我的程序集在安裝到 GAC 時在“添加引用 > .Net”中不可見?
有一個關於 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\我猜正因為如此,我無法從 Add Reference > .Net 中看到 Awesome.DLL。為什麼不安裝到
C:\Windows\Assembly\?我怎樣才能指向那個位置呢?
您的程序集安裝到
C:\WINDOWS\Microsoft.NET\assembly\而不是C:\Windows\Assembly\因為它是一個 .Net 4.0 程序集,並且 .Net 框架版本 4.0 在該位置有一個新的單獨 GAC。位於的 GACC:\Windows\Assembly\僅包含 .Net 2.0 - 3.5 程序集。(請參閱.NET 4.0 有一個新的 GAC,為什麼?)。在 Visual Studios“添加引用 -> .Net”中找到的程序集列表。對話框不僅僅是在 GAC 中找到的程序集列表(請注意,該列表中的大多數條目在 GAC 中也找不到)。
有關如何將程序集添加到此列表的資訊,請參閱以下文章(特別是“在添加引用對話框中顯示程序集”部分):
請注意,用於此的系統資料庫項對於不同版本的 Visual Studio 是不同的。