Is it possible to add sections to .config files that will not be scanned by ConfigurationManager

advertisements

I don't want to create separate configuration file for my app but store the data in the web.config.

I just want to put some XML there and manually parse it because current implementation of ConfigurationManager isn't appropriate for my case.

However, without dummy classes and properties I can't add my XML there without getting Configuration Error: Parser Error Message: Unrecognized element XXXXX. Even if I create dummy configuration classes I can't fix this error in all cases...

Is there any way to mark my XML not to be parsed so that I can use System.XML to manually get the data.

Thx.


Use System.Configuration.IgnoreSectionHandler.

Example:

<configuration>
  <configSections>
    <section
        name="myCustomSection"
        type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        allowLocation="false" />
  </configSections>
...
  <myCustomSection>
     ...
  </myCustomSection>
...
</configuration>