Hi Linda...
Actually, this completely avoided the question.
My understanding was that the new apis offered by
System.Configuration.Configuration and
ConfigurationManager.OpenExeConfiguration() were to address those cases where
a program wanted to examine values in valid config file *other* than
<myapp>.exe.config.
For AppSettings and ConnectionStrings, System.Configuration.Configuration is
near enough to the behavior of ConfigurationManager that it's easy to work
with.
My question was whether System.Configuration.Configuration had any concept
of backwards compatibility on other custom sections. I've found examples of
how to implement custom sections with the newer ConfigurationSection and
ConfigurationElement, but not anything on how to handle validly implemented
legacy sections.
DefaultSection seems to know how the custom section was implemented but I
haven't found any way to get to the detail from it.
Thanks
Mark
> Hi Mark,
>
[quoted text clipped - 42 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT] - 02 Oct 2007 07:31 GMT
Hi Mark,
Thanks for your feedback.
We will perform some research on this issue and get back to you ASAP.
Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Linda Liu [MSFT] - 05 Oct 2007 04:47 GMT
Hi Mark,
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
IConfigurationSectionHandler type.
Your scenario is the latter case because the
System.Configuration.NameValueSectionHandler type inherites from the
IConfigurationSectionHandler type.
After we get the DefaultSection object, we can retrieve the raw XML within
the DefaultSection object. The following is a sample:
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
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
IConfigurationSectionHandler'
https://msdn2.microsoft.com/en-us/library/ms228056.aspx
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
System.Configuration.ConfigurationManager.GetSection method.
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.
Sincerely,
Linda Liu
Microsoft Online Community Support
Linda Liu[MSFT] - 09 Oct 2007 12:19 GMT
Hi Mark,
How about the problem now?
If you have any question, please feel free to let me know.
Thank you for using our MSDN Managed Newsgroup Support Service!
Sincerely,
Linda Liu
Microsoft Online Community Support