【问题标题】:System.Runtime.Extensions requires a higher version of System.RuntimeSystem.Runtime.Extensions 需要更高版本的 System.Runtime
【发布时间】:2015-08-31 15:15:50
【问题描述】:

我正在 Visual Studio 中开发一个新的“类库(NuGet 包)”项目。一切都很顺利,直到有一天它开始引发关于 System.Runtime.Extensions 程序集的错误:

Assembly 'System.Runtime.Extensions' with identity 'System.Runtime.Extensions,
Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'System.Runtime,
Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher
version than referenced assembly 'System.Runtime' with identity 'System.Runtime,
Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

我检查了on NuGet,它似乎确实是真的,System.Runtime.Extensions 要求System.Runtime 至少为 4.0.20。

我尝试在project.json"dependencies" 部分更改以下行:

"System.Runtime": "4.0.10-beta-23019",

"4.0.20-beta-23019",但它告诉我“IOException 类型同时存在于System.IOSystem.Runtime。”

我能做些什么来解决这个问题?

谢谢。


编辑:刚刚在一个新的包项目上尝试了这个,它似乎也失败了,所以有些事情发生了。

【问题讨论】:

  • 应该是4.0.20-beta-**23109**而不是23019。数字非常相似,但是如果您查看版本历史记录,它会略有不同:nuget.org/packages/System.Runtime
  • @RonBeyer 试过了,它给了我提到的第二个错误。
  • 你在哪里添加的?在您的全局 dependencies 部分或 .NET Core TFM 的 dependencies 部分中? dnxcore50 例如。它应该只添加到 .NET Core TFM 中,因为完整的 .NET 框架会自行引用它。
  • @HenkMollema 我相信全局部分,我在project.json 中看不到它附近的任何 TFM。如何将其放入 TFM?

标签: c# asp.net .net nuget asp.net-core


【解决方案1】:

尝试仅将其添加到 .NET Core 目标框架:

{
    "dependencies": { },

    "frameworks": {
        "dotnet": {
            "dependencies": {
                "Microsoft.CSharp": "4.0.0",
                "System.Collections": "4.0.10",
                "System.Linq": "4.0.0",
                "System.Runtime.Extensions": "4.0.10",
                "System.Threading": "4.0.10"
            }
        }
    }
}

dnxcore50 是一个 .NET Core 目标框架。例如,也可以是dotnet

【讨论】:

  • 感谢您的帮助!不过,我刚刚添加了参考 (gist),但它仍然给出相同的错误。
  • @JamesKo 我已经更新了我的答案。只需将所有依赖项添加到dotnet
  • 不幸的是,这似乎给了我上面提到的第二个错误......我将对此提出另一个问题。
【解决方案2】:

解决方案只是明确指定我对System.Runtime.Extensions 的依赖:

"dependencies": {
    "System.Collections": "4.0.10-beta-23019",
    "System.Linq": "4.0.0-beta-23019",
    "System.Threading": "4.0.10-beta-23019",
    "System.Runtime": "4.0.10-beta-23019",
    "System.Runtime.Extensions": "4.0.0",
    "Microsoft.CSharp": "4.0.0-beta-23019"
},

所有的悲伤都是因为我想使用Environment.NewLine。哦。

【讨论】:

    猜你喜欢
    • 2016-03-28
    • 1970-01-01
    • 2020-12-11
    • 1970-01-01
    • 2015-05-24
    • 2017-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多