tavier
tavier

Reputation: 1794

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

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>

Upvotes: 1

Views: 2658

Answers (1)

Christian Pangestu
Christian Pangestu

Reputation: 96

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

Upvotes: 2

Related Questions