I am trying to create a section of a custom configuration file based on AppSettings:
<configSections> <section name="customConfiguration" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </configSections>
When I tried to read it through ConfigurationManager.GetSection ("customConfiguration"), the returned object was of type System.Configuration.KeyValueInternalCollection. I was unable to read the values ββof this collection, although I could see the keys, and I could not pass it to the AppSettingsSection.
This is Stackoverflow's answer suggesting to use
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); AppSettingsSection customSettingSection = (AppSettingsSection)config.GetSection("customConfiguration");
It worked. My question is: what is the difference between ConfigurationManager.GetSection () and Configuration.GetSection ()? When should I use one and when should I use the other?
source share