Solved

System.Configuration in .net 2.0 C#

Posted on 2006-11-15
3
210 Views
Last Modified: 2012-08-13
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
Comment
Question by:me_new
3 Comments
 
LVL 13

Accepted Solution

by:
joechina earned 100 total points
ID: 17947337
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question