IEnumerable<> 在未引用的程序集中定义 - 新 NuGet Class 库项目
IEnumerable<> is defined in an assembly that is not referenced - new NuGet Class Library project
我正在使用 VS2015 Community,我安装了 .NET 4.6.01040,我按照 these 说明安装 ASP.NET 5.
我想开始将站点从 MVC5 迁移到 MVC6 以及它附带的所有其他更新,因此我从包含我的数据模型的实体 Class 库项目开始。这是我的 project.json
文件的样子:
{
"version": "1.0.0-*",
"description": "test.Entities Class Library",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net461": {
"dependencies": { "System.Runtime": "4.0.0.0" }
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Linq": "4.0.1-beta-23516"
"System.Collections": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
}
}
我将框架类型从 "net451"
更改为 "net461"
因为我认为这是问题所在,我也尝试添加对依赖项的引用,但没有运气......
错误发生在这里:
[NotMapped]
public decimal TotalOrders => Math.Round(Orders.Where(x => x.Code.StartsWith("5")
.Sum(x => x.Amount),MidpointRounding.AwayFromZero);
完整的错误是:
CS0012 The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. test.Entity..NET Framework 4.6
知道如何使用新的项目类型进行这项工作吗?
net461
目标框架名称 (TFM) 表示完整的桌面 .NET Framework,如果您想从此框架引用 System.Runtime
,则需要将 "System.Runtime": "4.0.0.0"
条目移动到frameworkAssemblies
节点.
因为我从答案中不清楚需要什么,所以我会在这里提供....
{
"version": "1.0.0-*",
"description": "test.Entities Class Library",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net461": {
"dependencies": { "System.Runtime": "4.0.0.0" },
"frameworkAssemblies": {
"System.Runtime": "4.0.10.0"
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Linq": "4.0.1-beta-23516"
"System.Collections": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
}
}
我正在使用 VS2015 Community,我安装了 .NET 4.6.01040,我按照 these 说明安装 ASP.NET 5.
我想开始将站点从 MVC5 迁移到 MVC6 以及它附带的所有其他更新,因此我从包含我的数据模型的实体 Class 库项目开始。这是我的 project.json
文件的样子:
{
"version": "1.0.0-*",
"description": "test.Entities Class Library",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net461": {
"dependencies": { "System.Runtime": "4.0.0.0" }
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Linq": "4.0.1-beta-23516"
"System.Collections": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
}
}
我将框架类型从 "net451"
更改为 "net461"
因为我认为这是问题所在,我也尝试添加对依赖项的引用,但没有运气......
错误发生在这里:
[NotMapped]
public decimal TotalOrders => Math.Round(Orders.Where(x => x.Code.StartsWith("5")
.Sum(x => x.Amount),MidpointRounding.AwayFromZero);
完整的错误是:
CS0012 The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. test.Entity..NET Framework 4.6
知道如何使用新的项目类型进行这项工作吗?
net461
目标框架名称 (TFM) 表示完整的桌面 .NET Framework,如果您想从此框架引用 System.Runtime
,则需要将 "System.Runtime": "4.0.0.0"
条目移动到frameworkAssemblies
节点.
因为我从答案中不清楚需要什么,所以我会在这里提供....
{
"version": "1.0.0-*",
"description": "test.Entities Class Library",
"authors": [ "me" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"net461": {
"dependencies": { "System.Runtime": "4.0.0.0" },
"frameworkAssemblies": {
"System.Runtime": "4.0.10.0"
}
},
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Linq": "4.0.1-beta-23516"
"System.Collections": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
},
"dependencies": {
"EntityFramework.Core": "7.0.0-rc1-final",
}
}