简体   繁体   English

在.net 4.6.2中使用.net标准2.0库找不到System.Runtime 4.1.0.0

[英]System.Runtime 4.1.0.0 cannot be found using .net standard 2.0 lib in .net 4.6.2

I created a .NET standard 2.0 library and I am trying to use it in a 4.6.2 web api project. 我创建了.NET标准2.0库,并尝试在4.6.2 Web API项目中使用它。

When I try to run my web api, I get: 当我尝试运行Web API时,我得到:

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. 我在Web api项目中将.NET标准1.6作为nuget包。 What am I doing wrong? 我究竟做错了什么? (I upgraded .NET stndard to 2.0 in the web api project, but that didnt make a difference either) (我在Web api项目中将.NET stndard升级到2.0,但这也没有任何区别)

When I check the bin folder, the System.runtime.dll version is 4.6.255. 当我检查bin文件夹时,System.runtime.dll版本为4.6.255。 Why is the version higher than the nuget package it has added. 为什么版本比它添加的nuget包更高。

My package.config file has: 我的package.config文件具有:

<package id="System.Runtime" version="4.1.0" targetFramework="net462" />

The problem is described to the full extent here: https://github.com/dotnet/standard/issues/481 . 在此处完整描述了该问题: 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. 因此,在构建Web应用程序时,绑定重定向问题将显示在警告中。 In Visual Studio you need to double click that warning and you will be asked if you wish to add missing binding redirects. 在Visual Studio中,您需要双击该警告,然后询问您是否要添加缺少的绑定重定向。

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 在.net 4.6.2中使用.net标准1.5 lib缺少System.Runtime 4.1.0.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM