这是情况:
我有一个编译在 .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
I get the error:
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。
这一切都发生在同一台计算机上,具体来说就是我的开发工作站。
我可以将myDLL.dll从\bin\release文件夹复制到c:\Windows\assembly文件夹中,没有问题。但是尝试将policy.1.2.myDLL.dll文件从\bin\release复制粘贴到\assembly中,或者使用gacutil都失败了。
Assembly Linker version 10.0.30319.1
。当涉及到在全局程序集缓存中使用dll时,我有点新手。 - CurtisHx