I finally fixed the issue I reported in the post “New milestone reached in the development of the authoring tool for Tech Head Brothers French portal “. I am still waiting some feedback from Peter (he might be in holidays).

I am getting an exception when I try to deserialize an object. This exception is due to a security problem.

What I did is to use SGen tool from Daniel Cazzulino described in this post: “Strongly-typed, event-rising, design-time generated custom XmlSerializers (even more than Whidbey sgen!) “. I also used Mike Woodring code described in the post: “The Last Configuration Section Handler I’ll Ever Need“. I mixed all and modified XmlSerializerSectionHandler from Mike so that it doesn’t return a fixed IDictionary but an object. With reflection I can determine which Handler to instantiate, then from this handler I call it method Create and I get something like that to deserialize an object from the configuration file:

SchemaSettings schemaSettings = (SchemaSettings)AssemblySettings.GetConfig(“SchemaSettings”);

With the configuration:

<configuration>

<configSections>

<section name=”SchemaSettings”

type=”TechHeadBrothers.Configuration.XmlDynamicSerializerSectionHandler, THBPublisher”/>

</configSections>

<SchemaSettings type=”THBPublisher.SchemaSettings, THBPublisher” serializer=”THBPublisher.SchemaSettingsSerializer, THBPublisher” reader=”THBPublisher.SchemaSettingsReader, THBPublisher”>

<Name>Laurent</Name>

</SchemaSettings>

</configuration>

So the good point at the end is that I have a configuration file looking like a normal one, that I can get configuration settings from even deserialize object from it. Nice.