Re: multiple same section in app.config



I already tried your solution.
I got an exception "Sections must only appear once per config file".

"Sean Chambers" <dkode8@xxxxxxxxx> wrote in news:1158248668.638399.124870
@e3g2000cwe.googlegroups.com:

Perhaps moving the ID into an attribute on <Connection>

I.E.:

<Connection ID="2">
<add key="ComPort" value="COM4" />
<add key="Name" value="Connection 2" />
</Connection>

Droopy wrote:
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)

Loading