Serialization of Objects
Old forum URL: forums.lhotka.net/forums/t/859.aspx
TAX# posted on Wednesday, August 09, 2006
I have an object marked as [Serializable] based on csla.core.businessbase. When I attempt to serialize it using
public string ToXmlString()
{
XmlSerializer myS = new XmlSerializer(typeof(Employee));
MemoryStream ms = new MemoryStream();
StreamWriter myWriter = new StreamWriter(ms);
// TODO: CSLA serialization fails on broken rules collection
myS.Serialize(myWriter,this);
myWriter.Close();
StreamReader sr = new StreamReader(ms);
string outXml = sr.ReadToEnd();
return outXml;
}
The serialize line fails with an error suggesting that the BrokenRules collection is not serializable. Is this on purpose?
RockfordLhotka replied on Wednesday, August 09, 2006
CSLA objects are absolutely incompatible with the XmlSerializer. This serializer is designed for, and used by, Web Services. Chapter 11 contains good information about how to build web services on top of CSLA objects - and that same model is required for any other use of the XmlSerializer as well.
Copyright (c) Marimer LLC