Stenkross
Stenkross

Reputation: 557

System.Numerics when targeting net45

From what I've understood, it should be possible to target net45 with the new xproj/project.json project settings in Visual Studio 2015. So, I created a new project, under web templates in the file->new project menu, edited the project.json and Class1.cs as listed below.

project.json:

{
  "version": "1.0.0-beta8",

  "frameworks": {
    "net45": {
      "dependencies": {
        "System.Runtime.Numerics": "4.0.0"
      }
    }
  }
}

Class1.cs:

using System.Numerics;

namespace NumericTest
{
    public class Class1
    {
        public Class1()
        {
            var biginteger = BigInteger.Parse("1234567890");
        }
    }
}

The error I'm getting is:

.NET Framework 4.5 error CS0234: The type or namespace name 'Numerics' does not exist in the namespace 'System' (are you missing an assembly reference?)

If I update the target framework to "dotnet", it compiles just fine. But how do I use the System.Numerics (and more specifically, BigInteger class) when targeting net45?

Upvotes: 2

Views: 611

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172438

Try to add an assembly reference to System.Numerics.dll in your project.

Upvotes: 1

Related Questions