Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 811
zack Avatar asked Nov 17 '09 19:11

zack


People also ask

What is the use of ConfigurationManager in C#?

The ConfigurationManager class enables you to access machine, application, and user configuration information. This class replaces the ConfigurationSettings class, which is deprecated.

Does ConfigurationManager work in .NET core?

ConfigurationManager was added to support ASP.NET Core's new WebApplication model, used for simplifying the ASP.NET Core startup code.

How do I add a reference to System configuration ConfigurationManager?

Right click the project and choose add reference, browse "Assemblies" and tick the System. Configuration assembly.


1 Answers

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

like image 75
Philip Rieck Avatar answered Sep 20 '22 10:09

Philip Rieck