System.Runtime.Extensions需要更高版本的System.Runtime

时间:2015-08-31 15:15:51

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

我正在研究其中一个新的"类库(NuGet包)" Visual Studio中的项目。一切都很顺利,直到有一天它开始引发关于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。

我尝试更改"dependencies"的{​​{1}}部分中的以下行:

project.json

"System.Runtime": "4.0.10-beta-23019", ,但它告诉我"类型"4.0.20-beta-23019"同时存在于IOExceptionSystem.IO。"

我该怎么做才能解决这个问题?

感谢。

编辑:刚刚尝试了一个全新的软件包项目,它似乎也失败了,所以有些事情可以解决。

2 个答案:

答案 0 :(得分: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例如。

答案 1 :(得分:0)

解决方案只是明确指定我对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。 D'哦。

相关问题