Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access ConfigurationManager.AppSettings in a Windows Forms Application

How can I access ConfigurationManager.AppSettings in my Windows Forms Application?

The error message reads: The name 'ConfigurationManager' does not exist in the current context.

like image 889
cllpse Avatar asked Nov 25 '09 13:11

cllpse


People also ask

What is ConfigurationManager AppSettings?

it is a .net builtin mechanism to define some settings before the application starts, without recompiling. see msdn configurationmanager.

How do I get AppSettings in C#?

To access these values, there is one static class named ConfigurationManager, which has one getter property named AppSettings. We can just pass the key inside the AppSettings and get the desired value from AppSettings section, as shown below. When we implement the code given above, we get the output, as shown below.

Can I use ConfigurationManager 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 read app config file in C# Windows application?

Add the App. config file to your project. After creating a . NET Framework project, right-click on your project in Solution Explorer and choose Add > New Item. Choose the Application Configuration File item and then select Add.


3 Answers

Add a reference to System.Configuration.dll.

like image 169
SLaks Avatar answered Oct 26 '22 21:10

SLaks


I've had this experience before where I had to go and add a reference to System.Configuration to be able to use this funcitonality.

like image 40
Tinidian Avatar answered Oct 26 '22 23:10

Tinidian


Right click on your project in the solution explorer, select Add Reference then select the .Net tab (it should be selected by default), and select System.Configuration

like image 3
Mick Walker Avatar answered Oct 26 '22 23:10

Mick Walker