RE: Wanting to read XML blob from configuration

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks for your reply Nick,

For the further two problems you mentioned:


1. Get the XML for a section. As I said I think the .NET model is brain
dead and using the XML Serializer would have been much better, but that's
another debate. I plan on using the XML Serializer to deserialize the
configuration into a class. How can I get the XML for a section using the
NET 2.0 configuration model? I tried calling GetRawXml() but that fails
because I'm not in design mode.
==============================
For the "GetRawXml" method, it does has some code check internal that check
the design-time property and from the document, it also indicate that this
method is used by .net runtime internal and not intended to use by
developers directly. Therefore, for getting raw XML, you may need to use
XML api directly.

However, I'm still wondering what would you need to do through raw XML
parsing? What classes will you use to associate those configuration XML
content through XMLSerializer? The .net framework 2.0 has already provided
strong-typed classes that can help read and write configuration sections in
app or web.config file .e.g


System.Configuration.AppSettingsSection
System.Configuration.ConnectionStringsSection
System.Net.Configuration.AuthenticationModulesSection
System.Web.Configuration.AnonymousIdentificationSection
System.Web.Configuration.MachineKeySection
System.Net.Configuration.WebRequestModulesSection
System.Net.Configuration.SmtpSection
<<<<<<<<<<<<<<<<<<

also, these class also use XML API to parse the configuration file when get
initialized.




2. I would rather not have to add a <configSections> section to my
application configuration. I would rather at runtime tell the
configuration
manager what class will handle my section. But I don't see anyway to do
this.
=================================
the <configSections> element is used to provide the definition and handler
information of any custom/new configuration sections. This is necessary for
a section to be avalid in .net application config file. If you put a custom
section without definition in <configSections>, the .net runtime won't be
able to recognize and read it(since you haven't provided the handler class
for the section). Also such a configuration section with out
<configSections> definition is just like a normal XML fragment which is not
necessary to be saved in application config file. Is this what you want?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.










.



Relevant Pages

  • Re: DMProcessConfigXML CM_MAPPINGS
    ... documentation says is used for the standard mappings - and user mappings start at 0x1000000. ... Also while the first code example is 99% correct, you should free the returned string pointer with free not LocalFree e.g. ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: DMProcessConfigXML CM_MAPPINGS
    ... Also while the first code example is 99% correct, you should free the returned string pointer with free not LocalFree e.g. ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ... private extern static UInt32 DMProcessConfigXML(string xmlIn, UInt32 flag, out IntPtr xmlOutPtr); ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: app.config custom types
    ... Keep in mind my sample is not a direct KB on "how to implement a custom ... you gotta write the glue code which takes XML and converts it to a real ... This entry shows how to write a custom configuration handler (based on ...
    (microsoft.public.dotnet.languages.csharp)
  • DMProcessConfigXML CM_MAPPINGS
    ... I am using the following code to try to add a URL exception to the networks ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ... /// String of valid XML containing configuration data ...
    (microsoft.public.dotnet.framework.compactframework)
  • RE: Wanting to read XML blob from configuration
    ... I don't want to read any of .NET's configuration information. ... MyClass myClass; ... Get the XML for a section. ... a section to be avalid in .net application config file. ...
    (microsoft.public.dotnet.framework)