I don’t find any examples of how to access such a nested configuration section in a app.config
<my.configuration>
<emailNotification>
<to value="me@you.com" />
<from value="he@you.com" />
<subject value="Subject" />
<smtpHost value="smtp.you.com" />
<triggers>
<add name="1" varAlias="Var1" lower="-200" upper="-150"/>
</triggers>
</emailNotification>
</my.configuration>
I used ConfigurationElementCollection and ConfigurationElement before. But I don’t know how to do the above?
You need to:
Define
my.configurationas section group andemailNotificationas a section within the group. Add following to the configuration file:Implement the configuration section group (
my.configuration).Implement the configuration section (
emailNotification).Implement necessary configuration elements and configuration element collection.
After updating the configuration file and implementing necessary configuration bits, you can access you section as follows: