System.Numerics 以 net45 为目标时
System.Numerics when targeting net45
据我了解,应该可以在 Visual Studio 2015 中使用新的 xproj/project.json 项目设置来定位 net45。
因此,我创建了一个新项目,在文件-> 新项目菜单中的 Web 模板下,编辑了 project.json 和 Class1.cs,如下所示。
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");
}
}
}
我得到的错误是:
.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?)
如果我将目标框架更新为 "dotnet",它编译得很好。但是我如何在定位 net45 时使用 System.Numerics(更具体地说,BigInteger class)?
尝试在您的项目中添加对 System.Numerics.dll
的程序集引用。
据我了解,应该可以在 Visual Studio 2015 中使用新的 xproj/project.json 项目设置来定位 net45。 因此,我创建了一个新项目,在文件-> 新项目菜单中的 Web 模板下,编辑了 project.json 和 Class1.cs,如下所示。
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");
}
}
}
我得到的错误是:
.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?)
如果我将目标框架更新为 "dotnet",它编译得很好。但是我如何在定位 net45 时使用 System.Numerics(更具体地说,BigInteger class)?
尝试在您的项目中添加对 System.Numerics.dll
的程序集引用。