无法加载文件或程序集'System.Runtime.InteropServices'

问题描述 投票:0回答:1

我在我的.NetFramework 4.6.2项目中引用了一个针对.NetStandard和.NetFramework的nuget包。作为依赖,这个nuget包安装了System.Runtime.InteropServices包。但是现在当我试图通过浏览器访问我的服务时,我收到了这个错误:Could not load file or assembly 'System.Runtime.InteropServices, Version=4.0.0.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)

花了3个多小时试图解决这个问题。任何人都有任何修复?

这是我引用的nuget包:https://github.com/wavefrontHQ/wavefront-opentracing-sdk-csharp

以下是我的Web.config的样子:

        <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
      </dependentAssembly>
c# .net com-interop .net-standard .net-standard-2.0
1个回答
0
投票

您可以尝试删除下面的web.config条目。

<dependentAssembly>
 <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>

编辑:一些用户确认这种方法是从Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation工作

© www.soinside.com 2019 - 2024. All rights reserved.