ConfigurationSettings.AppSettings is obsolete

I've been porting some code from .NET 1.1 to .NET 2. The compiler gives me a few of the following error:

'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by ConfigurationManager.AppSettings'

It seems you can no longer do this:

System.Configuration.ConfigurationSettings.AppSettings[connstr].ToString();

You should do this instead:

System.Configuration.ConfigurationManager.AppSettings[connstr].ToString();

you then get an error where ConfigurationManager can't be found, apparently the System.Configuration.ConfigurationSettings class is found in the System.dll assembly. The ConfigurationManager class is found in the system System.Configuration.dll which must be referenced first.

About the Author

Steve Temple, Technical Director and co-founder of Gibe

Steve is Gibe's technical director and super brain behind the development of our major projects. With over 27 years of commercial experience, Steve is an expert in .NET, Umbraco and Microsoft technologies. Steve is also an Umbraco Certified Master and Microsoft MCSD