1

I created a .NET standard 2.0 library and I am trying to use it in a 4.6.2 web api project.

When I try to run my web api, I get:

Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

In my web config I have the following redirect:

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

I have .NET standard 1.6 as nuget package in the web api project. What am I doing wrong? (I upgraded .NET stndard to 2.0 in the web api project, but that didnt make a difference either)

When I check the bin folder, the System.runtime.dll version is 4.6.255. Why is the version higher than the nuget package it has added.

My package.config file has:

<package id="System.Runtime" version="4.1.0" targetFramework="net462" />
Kaladin
  • 693
  • 2
  • 11
  • 20

2 Answers2

0

The problem is described to the full extent here: https://github.com/dotnet/standard/issues/481. The solutions are described in the Workaround section.

So, when building a web application, binding redirect issues will be displayed in warnings. In Visual Studio you need to double click that warning and you will be asked if you wish to add missing binding redirects.

Edin
  • 1,476
  • 11
  • 21
-1

this question seems similar to your problem, take a look at it

Using .net standard 1.5 lib in .net 4.6.2 misses System.Runtime 4.1.0.0

  • Idk, maybe someone hated that I referenced another question :) – abdullah daoud Sep 14 '17 at 04:59
  • 1
    This should be a comment, **not an answer**. If the other question answers this question, then this should be dupe'd. It's also a *link only* answer, which is also **not an answer** – Rob Sep 14 '17 at 11:49
  • ok sorry for doing it wrong, I'm still new here and I'll get it right next time, thanks for the explanation. – abdullah daoud Sep 14 '17 at 12:11