Hello,
I need serialize and desirelize objects of Configuration Manager (http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx).
This is part of my code:
[Serializable] public class PropertyElement : ConfigurationElement { public PropertyElement() { } [ConfigurationProperty("name", IsKey = true)] public string Name { get { return ((string)(base["name"])); } set { base["name"] = value; } } [ConfigurationProperty("value")] public string Value { get { return ((string)(base["value"])); } set { base["value"] = value; } } }
An exception occurs when I try to serialize ConfigurationElement:
XmlSerializer serializer = new XmlSerializer(typeof(PropertyElement));Exception:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll
Additional information: There was an error reflecting type 'CustomConfigLoader.PropertyElement'.
InnerException:"You must implement a default accessor on System.Configuration.ConfigurationLockCollection because it inherits from ICollection."
How to serialize and deserialize ConfigurationElement object ?