Could not load file or assembly 'System.Runtime.InteropServices'

0

I am referencing a nuget package which is targeted to .NetStandard as well as .NetFramework in my .NetFramework 4.6.2 project. As a dependency, this nuget package installed System.Runtime.InteropServices package. But now when I am trying to access my service through browser I am getting this error: 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)

Spent like more than 3 hours trying to fix this one.Anyone with any fix?

This is the nuget package I am referencing: https://github.com/wavefrontHQ/wavefront-opentracing-sdk-csharp

And here is how my Web.config looks like:

        <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
asked on Stack Overflow Apr 1, 2019 by tavier

1 Answer

0

You can try removing the web.config entries below.

<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>

Edit: some users confirmed this approach to be working from Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation

answered on Stack Overflow Apr 1, 2019 by Christian Pangestu

User contributions licensed under CC BY-SA 3.0