Has VS 2015 changed drastically on how references are added?
I am doing a MVC web project. I wanted to use System.Configuration.ConfigurationManager
in my .NET 4.6 application. I went to the the References
node and Add Reference...
and added System.Configuration 1.0.0.0. Intellisense now was able to automatically provide the properties and methods for ConfigurationManager, eg ConfigurationManager.AppSettings
.
However, when I tried to compile, it says
CS0234 The type or namespace name 'Configuration' does not exist in the namespace 'System' (are you missing an assembly reference?)
How are things done in the new .NET Framework?
When I hover my mouse over the using System.Configuration
statement, there's a balloon text with yellow triangle and exclamation mark that says:
{} Namespace System.Configuration
MyProject.DNX 4.5.1 - Available
MyProject.DNX Core 5.0 - Not Available
You can use the navigation bar to switch context.
Whatever does this mean?
If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference.
It means that you have defined System.Configuration in DNX 4.5.1 which means is not available for DNX Core 5.0.
The project.json file is telling to the compiler that DNX Core 5.0 will be the main target framework. So if the System.Configuration namespace is not available in DNX Core 5.0 then you gonna get an error.
To solve this you need to switch the order of the frameworks defined in project.json
From:
"frameworks": {
"dnxcore50": {
},
"dnx451": {
}
}
To
"frameworks": {
"dnx451": {
},
"dnxcore50": {
}
}
Then you are telling to the compiler that your main target framework now is DNX 4.5.1 which is a more complete but dependent framework (.NET Framework 4.5.1 != .NET Core)
.NET Core is a very small subset of .NET Framework which is useful for running your applications in non-windows environments such as Linux and Mac.
If you are targeting Windows environments I strongly recommend to target DNX 4.5.1 or 4.6
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