October 26, 2012
Posted by on
Recently I hit an error trying to Serialize a IList (with the actual type being an ArrayList) in C#. The only error I could get was:
System.InvalidOperationException: There is an error in XML document
which was not particularly helpful. As far as I can tell the System.Xml.Serialization.XmlSerializer can’t serialise IList as the root node, but has no issues if the IList is a child node.
I found one workaround here that uses a IXmlSerializable wrapper for IList.
(I tried to use a z in serialise when it refers to a method, but couldn’t bring myself to break with Australian English for other uses!)