Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Runtime.Extensions requires a higher version of System.Runtime

I'm working on one of those new "Class Library (NuGet Package)" projects in Visual Studio. Everything was going fine until the other day it started raising an error about a System.Runtime.Extensions assembly:

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'

I checked on NuGet and it appears indeed to be true, System.Runtime.Extensions requires System.Runtime to be at least 4.0.20.

I tried changing the following line in the "dependencies" section of my project.json:

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

to "4.0.20-beta-23019", but then it tells me that "the type IOException exists in both System.IO and System.Runtime."

What can I do to fix this?

Thanks.


EDIT: Just tried this on a fresh new package project and it seems to be failing as well, so something's up.

like image 763
James Ko Avatar asked Oct 30 '22 20:10

James Ko


1 Answers

Try to add it only to .NET Core target frameworks:

{
    "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"
            }
        }
    }
}

Where dnxcore50 is a .NET Core target framework. Could also be dotnet for example.

like image 196
Henk Mollema Avatar answered Nov 09 '22 17:11

Henk Mollema