asp.net - How to use sections in an app.config that's in a web.config? -
my web.config looks this:
<configuration> <configsections> <appsettings configsource="exampleapp.config" /> <connectionstrings configsource="exampleprod.config" /> </configsections> <configuration>
my app.config (exampleapp.config) looks this:
<configsections> <sectiongroup name="examplesettings"> <section name="blah" type="system.configuration.namevaluesectionhandler" /> <section name="foo" type="system.configuration.namevaluesectionhandler" /> </sectiongroup> </configsections> <examplesettings> <blah> <add key="me" value="1" /> </blah> <foo> <add key="you" value="2" /> </foo> </examplesettings>
i'm getting error says: xml document cannot contain multiple root level elements. how resolve this?
as error specifies, need have 1 root element in xml file. put 2 parent elements in 1 parent element like,
<rootele> <configsections> <sectiongroup name="examplesettings"> <section name="blah" type="system.configuration.namevaluesectionhandler" /> <section name="foo" type="system.configuration.namevaluesectionhandler" /> </sectiongroup> </configsections> <examplesettings> <blah> <add key="me" value="1" /> </blah> <foo> <add key="you" value="2" /> </foo> </examplesettings> </rootele>
it should work.
Comments
Post a Comment