Solved

System.Configuration in .net 2.0 C#

Posted on 2006-11-15
3
209 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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