Re: multiple same section in app.config

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:uTAAXKO2GHA.4164@xxxxxxxxxxxxxxxxxxxx:

Droopy,

Well, it will, but you have to have one root element that is not
repeated.



So I must miss something !

I tried with the example provided in MSDN :

<myCustomGroup>
<myCustomSection myAttrib1="Clowns">
<myChildSection
myChildAttrib1="Zippy"
myChildAttrib2="Michael Zawondy "/>
</myCustomSection>
</myCustomGroup>

It works of course.
When I try to add a 2nd element :

<myCustomGroup>
<myCustomSection myAttrib1="Clowns">
<myChildSection
myChildAttrib1="Zippy"
myChildAttrib2="Michael Zawondy "/>
</myCustomSection>
<myCustomSection myAttrib1="Clowns2">
<myChildSection
myChildAttrib1="Zippy"
myChildAttrib2="Michael Zawondy "/>
</myCustomSection>
</myCustomGroup>

I got the same exception = "Sections must only appear once per config
file".


.



Relevant Pages

  • Re: How to debug SAX?
    ... > parser got presented and what causes the exception? ... The other thing to do is see if you can get *any* XML to parse. ... cause a "root element missing" error. ...
    (comp.lang.java.programmer)
  • XMLFilter exception
    ... throws the following exception (on certain input documents, not all and, ... alas, I were not able to locate the problem): ... root element of: HTML Nested exception: The node ... to this Document as it already has a root element of: ...
    (comp.lang.java.programmer)
  • Re: Reading data from XML with XDocument
    ... I really want to read the values who are inside the <config> element. ... "fuenteelementos", etc.), you can access them just as you access the child elements of the "elemento" element: ... Assuming that "config" is your root element, then just as you wrote 'elemento.Element', you can also write 'doc.Root.Element'. ... And of course, you definitely shouldn't ask "how can I read the first element called " if what you really want to know is how "to read the values who...only appear once" (given that it seems from your original post that "elemento" elements appear more than once and thus are specifically _not_ the ones you want to read, even though you specifically asked about reading those. ...
    (microsoft.public.dotnet.languages.csharp)
  • How do I restore a corrupted user.config file?
    ... "InitializeComponent" routine to throw the exception "Root element is ... when I start my app. ...
    (microsoft.public.dotnet.languages.csharp)
  • how to resolve System.Configuration.ConfigurationErrorsException?
    ... "InitializeComponent" routine to throw an exception "Root element is ... when I start my app. ...
    (microsoft.public.dotnet.languages.csharp)