0

I have a simple config section as follows

<configuration>
    <configSections>
        <section name="Test" type="System.Configuration.DictionarySectionHandler"/>
        <section name="Test1" type="System.Configuration.DictionarySectionHandler"/>
    </configSections>
    <Test>
        <add key="foo" value="1"/>
    </Test>
    <Test1>
        <add key="bar" value="20"/>
    </Test1>
</configuration>

And I am accessing it from code as

var blah = ConfigurationManager.GetSection("Test");

But I always get null. I tried everything but could not figure out whats going on. Could someone please help me with this?

Thanks,

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
gebs
  • 83
  • 1
  • 8
  • Is this a DLL project or an EXE project? – jglouie Feb 07 '16 at 21:15
  • 3
    It works for me. When I debug it, `blah` is of type `HashTable` and `blah["foo"] == 1`. What if you use `Hashtable blah = (Hashtable)ConfigurationManager.GetSection("Test")`? – Andrew Feb 07 '16 at 21:19
  • The config is in a console app project and the reading code in a class library. but I tried read it from the console app as well and got the same result. – gebs Feb 07 '16 at 22:17

0 Answers0