المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Serialization Problem



C# Programming
05-25-2010, 07:30 AM
I have a hierarchy of classes, all of which implement this interface:

public class IRuleObject
{
int Sequence { get; set; }
}
Here's the top level class:

[Serializable]
[XmlRoot("Group")]
public class RuleGroup : IRuleObject
{
[XmlAttribute("ID")]
public int GroupID { get; set; }

[XmlAttribute("Sequence")]
public int Sequence { get; set; }

[XmlAttribute("Name")]
public string GroupName { get; set; }

[XmlAttribute("Active")]
public bool Active { get; set; }

[XmlElement("Rules")]
public List Rules { get; set; }
}
You can see where it implements the interface.

When I attempt to serialize I get

Type 'RulesEngine.IRuleObject' in Assembly 'RulesEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
If I remove the interface, all works well. How do I set this up so i can use the interface & still serialize the
classes?
Everything makes sense in someone's mind