<appSettings> before <configSections> bug?

I am using System.Configuration.Configuration to access the "applicationSettings" data of some .config files, but when appSettings come first before configSection I can not find the "applicationSettings" SectionGroup in Configuration.SectionGroups.

When I put configSections first instead, the SectionGroup exists in the Configuration.SectionGroups.

Is this a bug or by design

Seems there are 4 standard SectionGroups that are allways there. With appSettings first the Configuration.SectionGroups.Count is 4. With configSections first the Configuration.SectionGroups.Count is 5 (since I only have one sectionGroup).



Answer this question

<appSettings> before <configSections> bug?

  • agarwaga

    Oh. Im using VS.Net 2005
  • Tom De Cort


    Hi Wolf5,

    This is by design.
    Actually appsetting is a kind of configSetions.
    If you look into the machine.config in the path below.
    <WINDOWS>\Microsoft.NET\Framework\v2.0.50727\CONFIG
    ==============================================================================
    < xml version="1.0" encoding="UTF-8" >
    <!--
    Please refer to machine.config.comments for a description and
    the default values of each configuration section.

    For a full documentation of the schema please refer to
    http://go.microsoft.com/fwlink/ LinkId=42127

    To improve performance, machine.config should contain only those
    settings that differ from their defaults.
    -->
    <configuration>
    <configSections>
    <section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
    ........
    ==============================================================================

    So our rule is configSections first and then other setting. This is just as the common programming rule, define a var first and then use it.

    If you still have any concern,please feel free to post here.

    Best regards,

    Peter Huang



  • DarrenK

    Would be nice if the compiler was able to see the <appSettings> before <configSections> situation and be able to tag a Warning on it.
  • Jeff Levinson

    Hi,

    Thanks for your feedback.
    I do understand your concern in this scenario, I highly suggest you can
    submit this feedback to our product feedback center:
    http://lab.msdn.microsoft.com/productfeedback/default.aspx


    Thanks for your understanding!

    If you still have any concern, please feel free to post here.

    Best regards,
    Peter Huang



  • <appSettings> before <configSections> bug?