Sekcja Custom Config w App.config C #


Jestem dość początkującym z sekcjami config w c #
Chcę utworzyć niestandardową sekcję w pliku konfiguracyjnym. To, co próbowałem po Google, jest następujące
Plik konfiguracyjny:

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="MyCustomSections">
      <section name="CustomSection" type="CustomSectionTest.CustomSection,CustomSection"/>
    </sectionGroup>
  </configSections>

  <MyCustomSections>
    <CustomSection key="Default"/>
  </MyCustomSections>
</configuration>


CustomSection.cs

    namespace CustomSectionTest
{
    public class CustomSection : ConfigurationSection
    {
        [ConfigurationProperty("key", DefaultValue="Default", IsRequired = true)]
        [StringValidator(InvalidCharacters = "~!@#$%^&*()[]{}/;'\"|\\", MinLength = 1, MaxLength = 60)]
        public String Key
        {
            get { return this["key"].ToString(); }
            set { this["key"] = value; }
        }
    }
}


Kiedy używam tego kodu do pobrania sekcji, pojawia się błąd z błędem konfiguracji.

var cf = (CustomSection)System.Configuration.ConfigurationManager.GetSection("CustomSection");


czego mi brakuje?
Dzięki.

Edytować
Ostatecznie potrzebuję

    <CustomConfigSettings>
    <Setting id="1">
        <add key="Name" value="N"/>
        <add key="Type" value="D"/>
    </Setting>
    <Setting id="2">
        <add key="Name" value="O"/>
        <add key="Type" value="E"/>
    </Setting>
    <Setting id="3">
        <add key="Name" value="P"/>
        <add key="Type" value="F"/>
    </Setting>
</CustomConfigSettings>

questionAnswers(3)

yourAnswerToTheQuestion