If you upgraded a project from .Net 1.0/1.1 to .Net 2.0, and it used application configuration files, you will soon come across the compiler warning message
‘System.Configuration.ConfigurationSettings.AppSettings’ is obsolete: ‘This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings’
You have to add a reference to the System.Configuration assembly, but once you do, you can just do a search and replace on ConfigurationSettings.AppSettings and replace it with ConfigurationManager.AppSettings and the functionality will remain the same.
The advantage of using ConfigurationManager is laid out in the MSDN docs, but briefly:
- Access sections other than appConfig, including connectionStrings, and your own custom sections
- Can read and write the configuration.
- It can have separate settings for the application and the users
- It’s extensible