Basically, App.config and Web.config are easy to deal with when it comes to connection strings and configuration key-value pairs.
But how to access additional sections of those two files?
The only way I can find implies that configuration/configSections/section
must be created in order to be able to add additional settings to the configuration files. This is false, since several .NET components actually access custom settings without using configuration/configSections/section
. For example, when dealing with diagnostics settings, I can have the section:
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="Samples">
<listeners>
<add name="ConsoleListener" type="System.Diagnostics.ConsoleTraceListener"/>
</listeners>
</source>
</sources>
</system.diagnostics>
without being required to add any configSection to the file.
How to do the same thing in my own code?