1

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>
tavier
  • 1,510
  • 2
  • 19
  • 43
  • 1
    So the web.config entries has no effect at all. Use fuslogvw.exe to troubleshoot. – Hans Passant Apr 01 '19 at 06:57
  • I took a look at fuslogvw, but it seems to be helpful if build fails for any assembly issues. But in my case, build is successful but I run into this when I try to access my service in a browser. – tavier Apr 01 '19 at 08:21

1 Answers1

2

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

  • I tried removing it but then my service returns 404 and crashes. – tavier Apr 01 '19 at 08:20
  • Can clarify what you mean by 404? Any error message? Have you checked if your service is able to access the System.Runtime.InteropServices.dll? Check if the dll is placed in the folder & permission is granted. – Christian Pangestu Apr 01 '19 at 09:03