I wrote my type derived from ConfigurationSection
tagged all properties with DataMember
and class with DataContract
, however program crashes stating I cannot inherit my type from a type that is not marked with DataContract
.
So how could I use this serializer with ConfigurationSection
?
[DataContract]
public sealed class MyConfig : ConfigurationSection
{
[DataMember]
[ConfigurationProperty("ConnectionTimeout", DefaultValue = 1000)]
public int ConnectionTimeout
{
get { return (int)this["ConnectionTimeout"]; }
set { this["ConnectionTimeout"] = value; }
}
... // other values
}