G
Guest
I'm doing what I thought was a very simple access of an app.config element in
a section, with no custom section handler, just NameValue. Here's the config
file:
<configuration>
<configSections>
<section name="MySection"
type="System.Configuration.NameValueSectionHandler" />
</configSections>
<MySection>
<add key="Company" value="MyCompany" />
</MySection>
</configurations>
And here's the code:
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
NameValueCollection nvc = (NameValueCollection)
config.GetSection("MySection");
I get a compiler error:
Error 52 Cannot convert type 'System.Configuration.ConfigurationSection' to
'System.Collections.Specialized.NameValueCollection'
I can't find any examples on the web about this, only older samples that use
ConfigurationSettings, not the preferred ConfigurationManager. Anybody know
what simple thing I'm doing wrong?
a section, with no custom section handler, just NameValue. Here's the config
file:
<configuration>
<configSections>
<section name="MySection"
type="System.Configuration.NameValueSectionHandler" />
</configSections>
<MySection>
<add key="Company" value="MyCompany" />
</MySection>
</configurations>
And here's the code:
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
NameValueCollection nvc = (NameValueCollection)
config.GetSection("MySection");
I get a compiler error:
Error 52 Cannot convert type 'System.Configuration.ConfigurationSection' to
'System.Collections.Specialized.NameValueCollection'
I can't find any examples on the web about this, only older samples that use
ConfigurationSettings, not the preferred ConfigurationManager. Anybody know
what simple thing I'm doing wrong?