I am trying to serialize a custom object into xml with this code:
MatchList matchList = converter.Convert(excelStream);
XmlSerializer xmlSerializer = new XmlSerializer(typeof(MatchList));
StringWriter stringWriter = new StringWriter();
xmlSerializer.Serialize(stringWriter, matchList);
string serializedXml = stringWriter.ToString();
txtResult.Text = serializedXml;
However I get the exception above in the 2nd line:
The matchlist object is defined as:
public class MatchList
{
public Header Header { get; set; }
[XmlArray("Lists")]
[XmlArrayItem("List")]
public virtual List<List> Lists { get; set; }
}
and add mark knownTypeAttribute with serializable types as
object