MarkMacrae Posted April 19, 2006 Posted April 19, 2006 Hi Im trying to serialize an object to XML (c#) using the System.XMLSerializer but Im getting exceptions due to the class being an interface (see code snippet below). string filename = @"C:\Mark\CODAAccount_" + myElement.Code + ".xml"; TextWriter tw = new StreamWriter(filename); XmlSerializer serializer = new XmlSerializer(typeof(codaElementClass)); serializer.Serialize(tw,myElement); I have read that there are ways I can implement the ISerializable interface which will allow me to serialize my object, but can anyone help me with this and provide some example syntax?? Thanks Mark Quote
Administrators PlausiblyDamp Posted April 20, 2006 Administrators Posted April 20, 2006 The XmlSerializer class needs to know about the class' data structures to be able to serialze it - interfaces do not have any data fields and therefore it cannot use them to determine storage requirements. If you are looking at implementing ISerializable yourself then this MSDN article is a good starting point. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.