I have plain c# console application (.NET 4.6) where I want to reference a .NET Core Class Library:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0",
"Newtonsoft.Json": "9.0.1"
},
"frameworks": {
"netstandard1.4": {
"imports": "dnxcore50"
}
}
}
And I get the following exception:
The type 'System. Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.
When you get this error, it means that code you are using makes a reference to a type that is in an assembly, but the assembly is not part of your project so it can't use it. Deleting Project. Rights. dll is the opposite of what you want.
Simple solution:
My .NET console application uses .NET 4.6 and should reference a Core Class Library using .NET Platform Standard 1.4.
Mapping the .NET Platform Standard to platforms says that .NET 4.6 is compatible with .NET Platform Standard 1.3.
Changing the project.json of the Core Class Library to (excerpt)
"frameworks": {
"netstandard1.3": {
"imports": "dnxcore50"
}
}
solved the problem.
Here is a compatibility table demonstrating the problem (.NET 4.6 is compatible with .NET Platform Standard <= 1.3):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With