I don’t have much experience on interactiong with config files and I was reading the GetSection() method in MSDN which notes that:
**Notes to Implementers**:
You must cast the return value to the expected configuration type.
To avoid possible casting exceptions, you should use a conditional
casting operation such as...
What does “configuration type” mean in this note? Are not the sections selected represents an xml node always?
Configuration Type is basically just the type of the custom class you define to represent the configuration values you want to store in the App.Config or Web.Config
Your custom config section needs to inherit from
System.Configuration.ConfigurationSectionand when you use theGetSectionmethod, you need to cast the return value as the type of your Custom class that you inherited off ofSystem.Configuration.ConfigurationSectionsee more here
An example would be if I had a special class to represent a property I wanted to store in either the App.Config or Web.Config such as:
Any time I would want to access that property I would do the following in my code: