Solved

System.Configuration in .net 2.0 C#

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now