使用 Microsoft.Bcl.Async
的 .NET 4.0 程序集在 RegAsm 时出现以下错误信息:
RegAsm : error RA0000 : Could not load file or assembly
'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The located assembly's manifest definition does not match
the assembly reference. (Exception from HRESULT: 0x80131040)
我的程序集(MyAssembly.dll
)使用了最新的 Microsoft.Bcl.Async
NuGet 包,这是项目的 packages.config
文件内容:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.165" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net40" />
</packages>
它捆绑了System.Threading.Tasks.dll
版本:2.6.6.0,这是该NuGet包的一部分。目标系统(带有.NET 4.0但没有.NET 4.5的Win7)上没有其他System.Threading.Tasks.dll
,无论是在GAC还是其他任何地方。
这是MyAssembly.dll.config
,它具有正确的bindingRedirect
元素用于System.Threading.Tasks
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.6.0" newVersion="2.6.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.6.0" newVersion="2.6.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.6.0" newVersion="2.6.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我的问题是:RegAsm不使用MyAssembly.dll.config文件吗?我该如何使其能够解析bindingRedirect指令?