<clear> Element for <configSections>
Clears all previously defined sections and section groups.
The <clear> element removes all sections and section groups from your application that were defined earlier in the current configuration file or at a higher level in the configuration file hierarchy.
The following example shows how to use the <clear> element in an application configuration file to clear sections previously defined in the machine configuration file.
The following machine configuration file code declares two sections, <
sampleSection> and <
anotherSampleSection>, which are read before the application configuration file.
<!-- Machine.config file. --> <configuration> <configSections> <section name="sampleSection" type="System.Configuration.SingleTagSectionHandler" /> <section name="anotherSampleSection" type="System.Configuration.NameValueSectionHandler" /> </configSections> <sampleSection setting1="Value1" setting2="value two" setting3="third value" /> </configuration>
The following application configuration file code clears all previously declared sections. The application cannot use or retrieve settings in either of the sections that were declared in the machine configuration file. However, it can use settings from
<anotherSection> because it comes after the <clear> element.
<!-- Application configuration file. --> <configuration> <configSections> <clear/> <section name="anotherSection" type="System.Configuration.NameValueSectionHandler" /> </configSections> </configuration>
This element can be used in the application configuration file, machine configuration file (Machine.config), and Web.config files that are not at the application directory level.