Reputation: 1735
I have created a solution with an ASP.NET 5 MVC6 project, and a few class libraries. I am using Visual Studio 2015, and I am targeting "dnxcore50" and "net451".
In a class library I am writing the repository code with EF7. In a class I am attempting to use a few methods on DbSet<>. Namely ".Where(...)", ".Single(...)" and ".First(...)". These were available on the older version of .NET.
I am getting the following 2 errors:
.NET Framework 4.5.1 error 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'.
.NET Framework 4.5.1 error CS0012: The type 'Func<,>' 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'.
It seems to build no problem in DNXCORE50 format, but not the full 4.5.1 version of .NET.
I have this in the project.json file:
"frameworks": {
"net451": {
"dependencies": {
"System.Runtime": "4.0.21-beta-23516"
}
},
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.21-beta-23516"
......
}
}
}
I am targetting 1.0.0-rc1-final DNX SDK version.
Any ideas?
Upvotes: 2
Views: 296
Reputation: 120
for additional answer we can still use net451 by adding "System.Runtime"
"net451": {
"frameworkAssemblies": {
"System.Runtime": ""
}
}
Upvotes: 1
Reputation: 1735
Ok, I finally think I managed to figure out why. If you create a class library, the project.json file has:
"net451": { },
in the "frameworks" section. If I change this to:
"dnx451": { },
it then works. I'm not 100% sure if this has a knock on to anything else. But I'll use that for now.
Upvotes: 6