[Question] Nesting NameValueSectionHandler/DictionarySectionHandler in Config File

Stack overflow.

I'm essentially trying to nest the original appSettings section, but all I really need is the key/value pairs.

Sample of what I'm trying to accomplish (devAppSettings.config):

<devAppSettings> <loggerSettings> </loggerSettings> <settings> <add key="dummy" value="value"/> </settings> </devAppSettings> 

I have the loggerSettings section working, but the settings section is where I'm getting errors.

"Property 'settings' is not a ConfigurationElement." 

Here is my class:

class ConfigSection : ConfigurationSection { [ConfigurationProperty("settings", IsDefaultCollection = false)] public DictionarySectionHandler Settings { get { return (DictionarySectionHandler)this["settings"]; } set { this["settings"] = value; } } } 

Config file:

<configuration> <configSections> <section name="devAppSettings" type="ConfigHelper.ConfigSection, ConfigHelper" /> </configSections> <devAppSettings configSource="devAppSettings.config"/> </configuration> 

by VOX_Studios via /r/csharp

Leave a Reply