Difference between ConfigurationSettings and ConfigurationManager

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:

  1. Access sections other than appConfig, including connectionStrings, and your own custom sections
  2. Can read and write the configuration.
  3. It can have separate settings for the application and the users
  4. It’s extensible

10 thoughts on “Difference between ConfigurationSettings and ConfigurationManager

  1. Ben Post author

    king, in Visual Studio, right-click on the project in Solution Explorer, from the .Net tab, scroll to choose System.Configuration, click Ok.

  2. Pingback: ConfigurationSettings Vs ConfigurationManager « Evolving Techie's Blog

  3. Sonny

    You ROCK Ben!!!!! Even after 4 years, your post was able to help me understand and resolve my issue.

  4. ajay Babu Devalla

    Inorder to add reference to System.Configuration we have to right click on the Project and click on ‘Add Reference’.
    Now a new window opens.Here click on .net Tab,Now Scroll down inorder to select the System.Configuration.Install.dll and click on the ‘select’ button.

    Now finally click ‘ok’ button to add reference

  5. Pingback: c# - Différence entre ConfigurationManager et ConfigurationSettings

Comments are closed.