问题描述
RegAsm失败了.NET 4.0组件,使用 Microsoft.Bcl.Async
以下消息:
RegAsm failing for a .NET 4.0 assembly using Microsoft.Bcl.Async
with the following message:
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程序 <$ C C $>)采用了最新的 Microsoft.Bcl.Async
的NuGet包,这里的项目 packages.config
:
My assembly (MyAssembly.dll
) uses the latest Microsoft.Bcl.Async
NuGet package, here's the project's 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包的一部分。有没有其他的 System.Threading.Tasks.dll
在目标系统上(Win7的使用.NET 4.0,但没有.NET 4.5),无论是在GAC也没有任何其他地方。
It bundles System.Threading.Tasks.dll
Version: 2.6.6.0 which is a part of that NuGet package. There is no other System.Threading.Tasks.dll
on the target system (Win7 with .NET 4.0 but without .NET 4.5), neither in GAC nor anywhere else.
下面是 MyAssembly.dll.config
,它具有正确的 bindingRedirect
为系统元素.Threading.Tasks
:
Here is MyAssembly.dll.config
, it has correct bindingRedirect
elements for 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
的说明?
My question: does RegAsm not use MyAssembly.dll.config
? How do I make it work so it resolves bindingRedirect
instructions?
推荐答案
我想出了解决的办法是一个黑客:
The solution I have come up with is a hack:
-
复制
RegAsm.exe
和RegAsm.exe.config
从Ç :\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ RegAsm.exe
到本地文件夹,其中MyAssembly.dll程序
是;
copied
RegAsm.exe
andRegAsm.exe.config
fromC:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe
to a local folder whereMyAssembly.dll
is;
修改 RegAsm.exe.config
来是这样的:
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
<supportedRuntime version="v4.0" sku="client" />
</startup>
<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.exe / codeBase的MyAssembly.dll程序
工作正常预期。 - now, running
RegAsm.exe /codebase MyAssembly.dll
works fine as expected.
有趣的是, useLegacyV2RuntimeActivationPolicy =真正的
已经去过那里的标准 RegAsm.exe.config
,但单独它并没有帮助。
Interestingly, useLegacyV2RuntimeActivationPolicy="true"
has already been there in the standard RegAsm.exe.config
, but alone it did not help.
我觉得这是此报告的同样的bug:https://connect.microsoft.com/VisualStudio/feedback/details/789318/asyncpack-system-io-fileloadexception-could-not-load-file-or-assembly-system-threading-tasks-version-1-5-11-0.
I think this is the same bug reported here: https://connect.microsoft.com/VisualStudio/feedback/details/789318/asyncpack-system-io-fileloadexception-could-not-load-file-or-assembly-system-threading-tasks-version-1-5-11-0.
这篇关于RegAsm失败了.NET 4.0使用Microsoft.Bcl.Async总成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!