Thursday, May 28, 2009

ReadOnlyNameValueCollection

Hey guys!

If you try using a System.Configuration.DictionarySectionHandler to store values that you need to come out in the order they're specified in the app.config, they'll actually come out in the order the hashing algorithm dumps them in there. So you have to use a System.Configuration.NameValueSectionHandler.

System.Configuration.ReadOnlyNameValueCollection is internal, but you can cast it to System.Collections.Specialized.NameValueCollection.

Also, the System.Configuration.ConfigurationManager class doesn't show up by default in Visual Studio 2008. You have to manually include a reference to System.Configuration.

It took me way too long to figure this out.