app.config

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stefano Meier

    app.config


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

    Gain technical skills through documentation and training, earn certifications and connect with the community


    the app.config file is:

    <configuratio n>
    <configSections >
    <section name="sampleSec tion"
    type="System.Co nfiguration.Sin gleTagSectionHa ndler" />
    <!--The following code declares a section group called
    mySectionGroup. -->
    <sectionGroup name="mySection Group">
    <section name="mySection "
    type="System.Co nfiguration.Nam eValueSectionHa ndler,System" />
    </sectionGroup>
    </configSections>

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

    And in code the following line generate the error:
    System.Configur ation.NameValue SectionHandler, system could not be provided

    NameValueCollec tion nvc = (NameValueColle ction)
    ConfigurationSe ttings.GetConfi g("mySectionGro up/mySection");

    Any idea why doesn't work?


  • Fabio Luiz Paranhos Borelli

    #2
    app.config

    Try this:

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

    []´s Fabio

    [color=blue]
    >-----Original Message-----
    >
    >I have tried the example on the following url but it has [/color]
    given me an error[color=blue]
    >
    >http://msdn.microsoft.com/library/en-[/color]
    us/cpguide/html/cpcondeclarings ectiongroups.as p[color=blue]
    >
    >the app.config file is:
    >
    ><configuration >
    > <configSections >
    > <section name="sampleSec tion"
    > [/color]
    type="System.Co nfiguration.Sin gleTagSectionHa ndler" />[color=blue]
    > <!--The following code declares a section group [/color]
    called[color=blue]
    >mySectionGroup . -->
    > <sectionGroup name="mySection Group">
    > <section name="mySection "
    > [/color]
    type="System.Co nfiguration.Nam eValueSectionHa ndler,System"
    />[color=blue]
    > </sectionGroup>
    > </configSections>
    >
    > <mySectionGroup >
    > <mySection>
    > <add key="key1:value 1" />
    > </mySection>
    > </mySectionGroup>
    ></configuration>
    >
    >And in code the following line generate the error:
    >System.Configu ration.NameValu eSectionHandler , system [/color]
    could not be provided[color=blue]
    >
    >NameValueColle ction nvc = (NameValueColle ction)
    >ConfigurationS ettings.GetConf ig[/color]
    ("mySectionGrou p/mySection");[color=blue]
    >
    >Any idea why doesn't work?
    >
    >
    >.
    >[/color]

    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: app.config

      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.
      [color=blue]
      > <section name="mySection "
      > type="System.Co nfiguration.Nam eValueSectionHa ndler,System,[/color]
      Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9"" />

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

      Hope this helps
      Jay


      "Stefano Meier" <stefanom234@fr eesurf.ch> wrote in message
      news:1061569754 .622710@fuchs.c yberlink.ch...[color=blue]
      >
      > I have tried the example on the following url but it has given me an error
      >
      >[/color]
      http://msdn.microsoft.com/library/en...tiongroups.asp[color=blue]
      >
      > the app.config file is:
      >
      > <configuratio n>
      > <configSections >
      > <section name="sampleSec tion"
      > type="System.Co nfiguration.Sin gleTagSectionHa ndler" />
      > <!--The following code declares a section group called
      > mySectionGroup. -->
      > <sectionGroup name="mySection Group">
      > <section name="mySection "
      > type="System.Co nfiguration.Nam eValueSectionHa ndler,System" />
      > </sectionGroup>
      > </configSections>
      >
      > <mySectionGroup >
      > <mySection>
      > <add key="key1:value 1" />
      > </mySection>
      > </mySectionGroup>
      > </configuration>
      >
      > And in code the following line generate the error:
      > System.Configur ation.NameValue SectionHandler, system could not be provided
      >
      > NameValueCollec tion nvc = (NameValueColle ction)
      > ConfigurationSe ttings.GetConfi g("mySectionGro up/mySection");
      >
      > Any idea why doesn't work?
      >
      >[/color]


      Comment

      Working...