RegAsm失败了.NET 4.0使用Microsoft.Bcl.Async总成

编程入门 行业动态 更新时间:2024-10-27 23:27:46
本文介绍了RegAsm失败了.NET 4.0使用Microsoft.Bcl.Async总成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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程序 )采用了最新的 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 and RegAsm.exe.config from C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe to a local folder where MyAssembly.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.
    • 有趣的是, useLegacyV2RuntimeActivati​​onPolicy =真正的已经去过那里的标准 RegAsm.exe.config ,但单独它并没有帮助。

      Interestingly, useLegacyV2RuntimeActivationPolicy="true" has already been there in the standard RegAsm.exe.config, but alone it did not help.

      我觉得这是此报告的同样的bug:connect.microsoft/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: connect.microsoft/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总成

本文发布于:2023-11-12 02:54:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580300.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:总成   失败了   NET   RegAsm   Async

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!