添加 Microsoft.AspNetCore 包后无法解析 System.Runtime.InteropServices.RuntimeInformation

aph*_*ph5 3 .net c# .net-core

我遇到了以下问题。

我创建了一个针对 .net framework 4.6.2 的新 lib 项目,并通过 NuGet 引用了 System.Runtime.InteropServices.RuntimeInformation 包。(对象浏览器显示该 dll 的版本为 4.0.1.0,(在 nuget 中我指向安装版本 4.3))

我重新加载项目,以检查引用是否有问题。

现在我安装了 Microsoft.AspNetCore,我重新加载了项目,对 System.Runtime.InteropServices.RuntimeInformation 和 System.Net.Htpp 的引用消失了。

在此处输入图片说明

附:安装 .netstandard 包没有帮助。

有没有人有类似的问题?

dou*_*lnt 7

System.Runtime.InteropServices.RuntimeInformation最低支持的 .net 框架版本是4.7.1. 您可以在System.Runtime.interopservices.runtimeinformation 中看到详细信息


aph*_*ph5 3

就我而言添加

<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

csproj 文件有帮助。我仍然缺少引用,但是在运行项目时我没有收到任何丢失文件的异常

  • 这可能与 Visual Studio 更新有关,更多信息请参见:https://developercommunity.visualstudio.com/content/problem/95070/could-not-load-file-or- assembly-systemruntime-vers.html (3认同)