[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

System.Configuration in .net 2.0 C#

Hi

Can anyone please let me know how to read this type of complex ConfigurationSection from App.config.
I am currently able to read simple Configuration Sections but as the complexity increase....i am unable read em...
as a sample i would aprreciate it if someone could write the classes needed for the below.

<ViewConfiguration>
    <View name="View1">
      <Controls>
        <Control name="Control1"/>
        <Control name="Control2"/>
      </Controls>
    </View>
    <View name="View2" >
      <Controls>
        <Control name="Control1"/>
        <Control name="Control2"/>
      </Controls>
    </View>
  </ViewConfiguration>


Thank u in advance.....
0
me_new
Asked:
me_new
1 Solution
 
joechinaCommented:
I bet you don't want to do that. You have to create your own ConfigurationSection handler.
Example see the How-To link from the following page.
http://msdn2.microsoft.com/en-us/library/ms228062.aspx

The other option is to modify your configuration file to

<sectionGroup name="ViewConfiguration">
      <section name="View1" type="System.Configuration.NameValueSectionHandler"/>
      <section name="View2" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>

<ViewConfiguration>
    <View1>
      <add key="Control1" value="anything you want to specify or you can leave it blank"/>
      <add key="Control2" value="..."/>    
    </View1>
    <View2>
      <add key="Control1" value="..."/>
      <add key="Control2" value="..."/>
    </View2>
</ViewConfiguration>

Then you can use .net 2.0 build in method to get the information out.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now