Re: multiple same section in app.config



Droopy,

The reason this doesn't work is that you are trying to create something
of a heiarchical nature for data that is simply a set of pairs.

If you want to use the NameValueSectionHandler, then you need to do
something like this:

<Connections>
<add key="ComPort_1" value="COM2" />
<add key="Name_1" value="Connection 1" />
<add key="ComPort_2" value="COM4" />
<add key="Name_2" value="Connection 2" />
</Connections>

Then, you would have to parse the names to see how the values are
grouped together.

If you want to have a different kind of config setup, then you will have
to create your own custom handler.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Droopy" <droopytoonnospam@xxxxxxxxxxx> wrote in message
news:Xns983EB244CE24Fdroopytoonnospamhotm@xxxxxxxxxxxxxxxxx
Hi,

I would like to configure some device connections through app.config.
I created the following config file but it fails because I have the same
section more than once :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="Connections">
<section name="Connection"
type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</configSections>
<Connections>
<Connection>
<add key="ComPort" value="COM2" />
<add key="Name" value="Connection 1" />
<add key="ID" value="1" />
</Connection>
<Connection>
<add key="ComPort" value="COM4" />
<add key="Name" value="Connection 2" />
<add key="ID" value="2" />
</Connection>
</Connections>
</configuration>

I have 2 questions :

1) How should I modify this configuration file ?
2) Now that ConfigurationSettings.GetConfig is obsolete, is does not
seems clear for me how to use ConfigurationManager to read the config
file.

Thanks in advance,

Droopy.



.



Relevant Pages

  • Re: Need Help on setting up a small home site.
    ... > told me that I have to open that port and forward request to my ... computer is the first network device. ... connections to port 80, so that they can be routed through to something ... > So if U don't consider it rude to post a long config file here, ...
    (comp.infosystems.www.servers.unix)
  • re: rblsmtpd/qmail-smtpd hung processes
    ... After a while the server just quits accepting smtp connections, or will connect/disconnect very quickly. ... I only had about 3 weeks notice on this and I've been configuring a pair of FreeBSD machines to take over DNS and E-Mail for about a dozen sites. ... Basically I've been on a crash course of learning as I go. ... The file "toaster.conf" file needs to be 644 so that when rotating logs, the programs can re-read the config. ...
    (freebsd-questions)
  • Re: port forwarding and ipfw rules
    ... redirect any connections to .19.110:443 to .19.109:443 ... redirect_port tcp .19.109:443 .19.110:443 ... Also my g/w is currently 5.2.1 but the config should be same ... fxp0: flags=8943mtu 1500 ...
    (freebsd-net)
  • deserialize to C# class from external config file?
    ... from an externally specified config file and deserialize ... the <connections> element seen below. ... still I can't get the deserialize to succeed. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: [fw-wiz] Cisco VPN Client "Stateful Firewall (Always On)"
    ... under network config in Windows 2000/NT. ... I have insisted that a firewall be included in this ... Basically, as I understand it, this feature allows all outbound ... connections while active, and all inbound connections originally established ...
    (Firewall-Wizards)