views:

594

answers:

2

I would like to use my own custom XML format in my Web.config. In .Net 1.1 I was using IConfigurationSectionHandler combined with XmlSerializer. Because IConfigurationSectionHandler is depreciated, I want to do the same with ConfigurationSection. I tried it like this:

    protected override void DeserializeSection(System.Xml.XmlReader reader)
    {
        // my custom code to deserialize data from reader
    }

If I start my application, I get a Parser Error saying: "Unrecognized configuration section mySection/customChildNode". This happens before DeserializeSection is called. What am I doing wrong? Any hint how to use custom xml in a ConfigurationSection?

Edit: a bit mor code as requested

I tried to implement my section like this:

public class MySection : ConfigurationSection
{
    protected override void DeserializeSection(XmlReader reader)
    {
        // my code
    }
}

and register it in the Web.config like this:

<sectionGroup name="mySection" type="myNamspace.MySection, myAssembly"/>

then I try to use it like this:

<mySection>
  <abc><xx/></abc>
</mySection>

I would assume that the DeserializeSection of my ConfigurationSection is called and the passed in XmlReader allows access to the contained custom XML. But DeserializeSection is not called and a get an error saying that mySection/abc is unknown.

A: 

Try using <section> instead of <sectionGroup>.

John Saunders
Stupid error. ;-) Thanks a lot!
Achim
A: 

I have an article on how to create custom configuration sections without using IConfigurationSectionHandler. Please have a look athttp://devpinoy.org/blogs/jakelite/archive/2009/01/10/iconfigurationsectionhandler-is-dead-long-live-iconfigurationsectionhandler.aspx

jake.stateresa