app.config

  • Thread starter Thread starter Stefano Meier
  • Start date Start date
S

Stefano Meier

I have tried the example on the following url but it has given me an error

http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondeclaringsectiongroups.asp

the app.config file is:

<configuration>
<configSections>
<section name="sampleSection"
type="System.Configuration.SingleTagSectionHandler" />
<!--The following code declares a section group called
mySectionGroup. -->
<sectionGroup name="mySectionGroup">
<section name="mySection"
type="System.Configuration.NameValueSectionHandler,System" />
</sectionGroup>
</configSections>

<mySectionGroup>
<mySection>
<add key="key1:value1" />
</mySection>
</mySectionGroup>
</configuration>

And in code the following line generate the error:
System.Configuration.NameValueSectionHandler, system could not be provided

NameValueCollection nvc = (NameValueCollection)
ConfigurationSettings.GetConfig("mySectionGroup/mySection");

Any idea why doesn't work?
 
Try this:

<mySectionGroup>
<mySection>
<add key="key1" value="value1" />
</mySection>
</mySectionGroup>

[]´s Fabio

-----Original Message-----

I have tried the example on the following url but it has given me an error

http://msdn.microsoft.com/library/en- us/cpguide/html/cpcondeclaringsectiongroups.asp

the app.config file is:

<configuration>
<configSections>
<section name="sampleSection"
type="System.Configuration.SingleTagSectionHandler" />
 
Stefano,
Removing ",System" from the type on mySection I got your sample to work.

Also if I give the fully qualified name I got your sample to work.
<section name="mySection"
type="System.Configuration.NameValueSectionHandler,System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" />

I'm sure I had a sample where giving just ", System" succeeded, now I cannot
find it...

Hope this helps
Jay
 
Back
Top