【问题标题】:System.Runtime 4.1.0.0 cannot be found using .net standard 2.0 lib in .net 4.6.2在 .net 4.6.2 中使用 .net 标准 2.0 库找不到 System.Runtime 4.1.0.0
【发布时间】:2018-02-22 13:17:10
【问题描述】:

我创建了一个 .NET 标准 2.0 库,并尝试在 4.6.2 Web api 项目中使用它。

当我尝试运行我的 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.

在我的网络配置中,我有以下重定向:

<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>

我在 web api 项目中有 .NET 标准 1.6 作为 nuget 包。我究竟做错了什么? (我在 web api 项目中将 .NET 标准升级到 2.0,但这也没有什么不同)

当我检查 bin 文件夹时,System.runtime.dll 版本是 4.6.255。为什么版本高于它添加的nuget包。

我的 package.config 文件有:

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

【问题讨论】:

  • 有什么理由不更新重定向到4.6.255的版本吗?
  • @KevinHirst 我尝试重定向到 4.6.255,但这也无济于事。我想知道在 .net 框架 4.6.2 项目中使用 .net 标准库是否存在某种问题?
  • @Win 我看到了那个帖子,但它对我没有帮助。
  • 复习微软所说的,github.com/dotnet/standard/issues/481

标签: c# asp.net .net visual-studio-2017 .net-standard


【解决方案1】:

这里全面描述了这个问题:https://github.com/dotnet/standard/issues/481。解决方案在解决方法部分中进行了描述。

因此,在构建 Web 应用程序时,绑定重定向问题将显示在警告中。在 Visual Studio 中,您需要双击该警告,系统会询问您是否要添加缺少的绑定重定向。

【讨论】:

    【解决方案2】:

    这个问题好像和你的问题差不多,看看吧

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

    【讨论】:

    • Idk,也许有人讨厌我引用了另一个问题 :)
    • 这应该是评论,不是答案。如果另一个问题回答了这个问题,那么这应该是被欺骗的。这也是一个仅链接答案,这也是不是答案
    • 好的抱歉做错了,我还是新手,下次我会做的,谢谢你的解释。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-25
    • 2016-11-13
    • 1970-01-01
    • 2016-11-08
    相关资源
    最近更新 更多