Reputation: 16234
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?
Upvotes: 10
Views: 3293
Reputation: 627
The message You can use the navigation bar to switch context. shows when you have projects that use files added as link (context menu of a project and then Add->Existing Item...->Add As Link).
Example: assume that you have a C# file called sample.cs in a project ProjectA and the same file is referenced as a link in ProjectB. Then you write in sample.cs some code that uses library called Library. You also have reference to this Library only in ProjectA. So the ProjectB should also have reference to that library. If not - then this message appears: You can use the navigation bar to switch context. Full example message:
{} Namespace Library
ProjectA 1.0.0 - Available
ProjectB 1.0.0 - Not Available
You can use the navigation bar to switch context.
Upvotes: 0
Reputation: 633
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
Upvotes: 2
Reputation: 2063
Sorry that I still cant put a comment with my current points.
I suggest the things that you should do :
Im using System.Configuration 4.0.0.0 and its working fine in Visual Studio 2015
you could check more in here
Upvotes: 0