The name 'ConfigurationManager' does not exist in the current context
In your project, right-click, Add Reference..., in the .NET tab, find the System.Configuration
component name and click OK.
using System.Configuration
tells the compiler/IntelliSense to search in that namespace for any classes you use. Otherwise, you would have to use the full name (System.Configuration.ConfigurationManager
) every time. But if you don't add the reference, that namespace/class will not be found anywhere.
Note that a DLL can have any namespace, so the file System.Configuration.dll
could, in theory, have the namespace Some.Random.Name
. For clarity/consistency they're usually the same, but there are exceptions.
Ok.. it worked after restarting the VSTS. The link suggested the solution for the same problem. Wish i could have seen it before. :)
It's not only necessary to use the namespace System.Configuration
. You have also to add the reference to the assembly System.Configuration.dll
, by
- Right-click on the References / Dependencies
- Choose Add Reference
- Find and add
System.Configuration
.
This will work for sure.
Also for the NameValueCollection
you have to write:
using System.Collections.Specialized;