gpt4 book ai didi

c# - IEnumerable<> 在未引用的程序集中定义 - 新的 NuGet 类库项目

转载 作者:太空狗 更新时间:2023-10-29 22:15:49 24 4
gpt4 key购买 nike

我正在使用 VS2015 Community,我安装了 .NET 4.6.01040 并且我关注了 these安装 ASP.NET 5 的说明。

我想开始将站点从 MVC5 迁移到 MVC6 以及它附带的所有其他更新,因此我从包含我的数据模型的实体类库项目开始。这是我的 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

关于如何使用新项目类型进行这项工作有什么想法吗?

最佳答案

因为我从答案中不清楚需要什么,所以我会在这里提供....

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

关于c# - IEnumerable<> 在未引用的程序集中定义 - 新的 NuGet 类库项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33804858/

24 4 0