Good, therefore .....
<section name="test" type="System.Configuration.NameValueFileSectionHandler" /> <test> <add key="foo" value="bar" /> </test> var test = ConfigurationManager.GetSection("test");
So far so good. The debugger shows that test contains one key, foo .
But GetSection returns object , so we need cast:
var type = test.GetType();
Well, that should be simple enough. So....
using System; var test = ConfigurationManager .GetSection("test") as ReadOnlyNameValueCollection;
Error!
The type or namespace ReadOnlyNameValueCollection does not exist in the namespace System.Configuration. Are you missing an assembly reference?
err ... wtf?
Casting to System.Collections.Specialized.NameValueCollection causes the code to work, but I really don't understand why the error.
And a search on ReadOnlyNameValueCollection on MSDN shows that there is no documentation for this class at all. It does not seem to exist. However, I have an instance of this type in my code.
source share