Sorry for the delay!
The System.Configuration.DefaultSection represents a basic
configuration-section handler that exposes the configuration section's XML
for both read and write access.
This is the type that is returned when the design-time API reads in a
section that is not registered in the <configSections> section. This type
is also returned when the type of registered section does not inherit from
ConfigurationSection, as with sections that use the .NET 1.0 or 1.1
Your scenario is the latter case because the
System.Configuration.NameValueSectionHandler type inherites from the
After we get the DefaultSection object, we can retrieve the raw XML within
the DefaultSection object. The following is a sample:
Configuration config =
ConfigurationSection section = config.Sections["Test"];
// in your practice, the variable 'xml' returns "<Test>\r\n <add
key=\"test\" value=\"this\"/>\r\n </Test>"
string xml = section.SectionInformation.GetRawXml();
As we can see, it's not convenient to get the value of the key 'test' from
the above variable 'xml'.
The following MSDN document introduces how to create custom configuration
sections using IConfigurationSectionHandler as well as how to
programmatically access the custom configuration data:
'How to: Create Custom Configuration Sections Using
As you can see, the sample in the above document uses the
System.Configuration.ConfigurationSettings.GetConfig method to access the
custom configuration data. If you look up this method in MSDN, you'll find
this method is now obsolete and has been replaced by
So we should use ConfigurationManager.GetSection method to configuration
sections that inherties from the IConfigurationSectionHanlder type.
Hope this helps.
If you have anything unclear, please feel free to let me know.
Microsoft Online Community Support