This project has moved. For the latest updates, please go here.

Why Class is not generated for ConfigurationSectionGroup ?

Apr 23, 2012 at 7:27 AM
Edited Apr 23, 2012 at 8:05 AM

In my configuration section design, I have added a 'ConfigurationSectionGroup' (named webAppConfigSectionGroup) having two 'ConfigurationSection' (named 'PageSettingsSection','AppearanceSection') sections; But I do not find the generated calss for the SectionGroup. I was expecting a class like so:

 

public class WebAppConfigSectionGroup : ConfigurationSectionGroup
    {
        public WebAppConfigSectionGroup(): base()
        {             
        }
 
        [ConfigurationProperty("pageSettings")]
        public PageSettingsSection PageSettingsSection
        {
            get {
                return this.Sections["pageSettings"] as PageSettingsSection;
            }
        }
 
        [ConfigurationProperty("appearance")]
        public AppearanceSection AppearanceSection
        {
            get
            {
                return this.Sections["appearance"] as AppearanceSection;
            }
        }
    }

 

It seems the sections are not aware of their parent SectionGroup. Am I missing something?

If I define the 'WebAppConfigSectionGroup' class manually, and also change the type property in .config file, it works fine.

 

<configSections>
    <sectionGroup name="webAppConfigSectionGroup" type="Web.App.Config.WebAppConfigSectionGroup, Web.App.Config">
      <section name="pageSettings" type="Web.App.Config.PageSettingsSection, Web.App.Config"/>
      <section name="appearance" type="Web.App.Config.AppearanceSection, Web.App.Config"/>
    </sectionGroup>
  </configSections>