Error: The name 'ConfigurationManager' does not exist in the current context

C#Configurationmanager

C# Problem Overview


I have included the following statement in my Visual C# Console Application (Visual Studio 2005 .NET 2.0 Framework)

using System.Configuration;

and I am using the following statement in my application:

ConfigurationManager.AppSettings["SomeStringOverHere"];

I try to build the application and I get the error: The name 'ConfigurationManager' does not exist in the current context.

Any help please?

C# Solutions


Solution 1 - C#

You need to reference System.Configuration.dll in your project as well as the "using" statement.

Namespaces are (sometimes) "split" across assemblies. That means that types in a single namespace are actually in different assemblies.

To determine which assembly a BCL or FCL type is in, look it up on MSDN. If you look at the help for ConfigurationManager, you'll see that it specifies that it's in the System.Configuration assembly by looking near the top at "Assembly". This is the assembly you need to reference from your project

Solution 2 - C#

Philip was correct adding the reference helped me, but I actually went and tried to download the DLL because I did not know there was an easier way...

  1. right-click on 'add references' folder in the solution explorer
  2. select the '.NET' tab
  3. search for the .NET reference you would like to add (in this case System.Configuration)

This post was very helpful to me, thanks to all.

Solution 3 - C#

  • at the solution explorer
  • select References
  • then click Add Reference from the right mouse button menu

enter image description here

  • in the top right corner write "Configuration:
  • check the System.Configuration, which would show up
  • press OK

enter image description here

Solution 4 - C#

I faced the same problem too.

I have 2 projects 1 main and 1 DLL. I have App.config file in the same Place But Connection string was defined in DLL but not in main project which is executable one as main. after adding / moving the connection string to main project APP.CONFIG file, the issue resolved.

Hope this helps

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzackView Question on Stackoverflow
Solution 1 - C#Philip RieckView Answer on Stackoverflow
Solution 2 - C#Taylor BrownView Answer on Stackoverflow
Solution 3 - C#VityataView Answer on Stackoverflow
Solution 4 - C#ಅನಿಲ್View Answer on Stackoverflow