IEnumerable的&LT;&GT;新的NuGet类库项目 - 在未引用的程序定义 [英] IEnumerable<> is defined in an assembly that is not referenced - new NuGet Class Library project
问题描述
我使用VS2015的社区,我安装了.NET 4.6.01040我也跟着的这些说明安装ASP.NET 5。
I'm using VS2015 Community, I have .NET 4.6.01040 installed and I followed these instructions to install ASP.NET 5.
我要开始MVC5一个站点迁移到MVC6所有附带的其他更新,所以我就开始与持有我的数据模型实体类库项目。这是我的 project.json
文件的样子:
I want to start migrating a site from MVC5 to MVC6 all the other updates that came with it, so I started with the Entity Class library project that holds my Data model. This is how my project.json
file looks like:
{
"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
,因为我认为这是问题,我也试图引用添加到依赖,但没有运气...
I changed the framework type from "net451"
to "net461"
cause I thought that that was the problem, and I also tried to add the reference to the dependencies, but no luck...
该错误是发生在这里:
[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
如何使这项工作与新的项目类型的任何想法?
Any idea on how to make this work with the new project types?
推荐答案
net461
目标框架名(TFM)再presents完整的桌面.NET Framework和若你想从这个框架中引用 System.Runtime
,你需要移动System.Runtime:4.0.0.0
进入 frameworkAssemblies
节点。
net461
target framework name (TFM) represents the full desktop .NET Framework and if you want to reference System.Runtime
from this framework, you need to move the "System.Runtime": "4.0.0.0"
entry to frameworkAssemblies
node.
这篇关于IEnumerable的&LT;&GT;新的NuGet类库项目 - 在未引用的程序定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!