這裏的情況:gacutil和環境造成重大頭痛的小版本差異
我有一個在.NET 2中編譯的DLL在全局程序集緩存中。我有myDLL.dll.config
文件內容如下:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="myDLL" publicKeyToken="c426c33bab532523" />
<bindingRedirect oldVersion="1.2.2.0-1.2.2.22" newVersion="1.2.2.23" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
然後我用匯編器來創建策略文件:
al /link:myDLL.dll.config /out:policy.1.2.myDLL.dll /keyfile:myDLL.snk
但是,當我嘗試將政策文件加載到使用
全局程序集緩存gacutil -i policy.1.2.myDLL.dll
我得到的錯誤:
Failure adding assembly to the cache: This assembly is built by a
runtime newer than the currently loaded runtime and cannot be loaded.
的.NET全局程序集緩存實用程序的版本是2.0.50727.42,但我通過創建一個新的C#.NET 2控制檯項目,並執行檢查的編譯環境的版本如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
MessageBox.Show(Environment.Version.ToString());
}
}
}
和我Environment.Version是2.0.50727.5466。
這一切發生在同一臺計算機上,具體而言,我開發框。
我可以從\ Bin \ Release文件複製到MYDLL.DLL C:\ WINDOWS \ assembly文件夾,沒有問題。但是,試圖要麼複製過去從\ BIN \發佈policy.1.2.myDLL.dll文件\組裝,或使用GACUTIL失敗。
http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/e76f5c46-e679-4923-bf9d-1f883074eb2e/? –
您確定您使用的是.NET 2.x版本的al? –
@TimB我不確定。我打開了一個新的Visual Studio 2010命令提示符,輸入「al」,得到了「Assembly Linker version 10.0.30319.1'。在全局程序集緩存中使用dll時,我有點新意。 – CurtisHx