tags:

views:

1172

answers:

5

In .net frameworks 1.1, I use

System.Configuration.ConfigurationSettings.AppSettings["name"];

for application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this:

System.Configuration.ConfigurationManager.AppSettings["name"];

The problem is, ConfigurationManager was not found in the System.Configuration namespace. I've been banging my head against the wall trying to figure out what I'm doing wrong. Anybody got any ideas?

+9  A: 

You have to reference the System.configuration assembly (note the lowercase)

I don't know why this assembly is not added by default to new projects on Visual Studio, but I find myself having the same problem every time I start a new project. I always forget to add the reference.

Sergio Acosta
A: 

You are missing the reference to System.Configuration.

FantaMango77
+1  A: 

If you're just trying to get a value from the app.config file, you might want to use:

ConfigurationSettings.AppSettings["name"];

That works for me, anyways.

/Jonas

Joda
A: 

Visual Studio doesn't make it obvious which assembly reference you need to add. One way to find out would be to look up ConfigurationManager in the MSDN Library. At the top of the "about ConfigurationManager class" page it tells you which assembly and DLL the class is in.

Rory MacLeod
A: 

System.Configuration us refer to System.configuration (not the small case for configuration, in .net 2.o it reefers to System.Configuration.dll.