Hello,
I'm working with C#, Framework 3.5 (VS 2008).
I'm using the ConfigurationManager to load a config (not the default app.config file) into a Configuration object.
using the Configuration class, i was able to get an ConfigurationSection, but i could not find a way to get the values of that section.
in the config, the ConfigurationSection is of type "System.Configuration.NameValueSectionHandler".
For what it worth, when i used the method "GetSection" of the ConfigurationManager (works only when it was on my default app.config file), i received an object type, that i could cast into collection of pairs of key-value, and i just received the value like a Dictionary. i could not do such cast when i received ConfigurationSection class from the Configuration class however.
Thanks alot, Liran.
EDIT:
Example of the config file:
<configuration>
<configSections>
<section name="MyParams" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<MyParams>
<add key="FirstParam" value="One"/>
<add key="SecondParam" value="Two"/>
</MyParams>
</configuration>
Example of the way i was able to use it when it was on app.config (the "GetSection" method is for the default app.config only):
NameValueCollection myParamsCollection =
(NameValueCollection)ConfigurationManager.GetSection("MyParams");
Console.WriteLine(myParamsCollection["FirstParam"]);
Console.WriteLine(myParamsCollection["SecondParam"]);