我想序列化一个IList集合。但它无法在代码中生成XML文档。我得到的错误是“有问题XMLSerialize引发异常。试图序列化一个列表,但得到了错误
System.InvalidOperationException
{"There was an error generating the XML document."}
这里是我的代码
IList<TwitterStatus> statuses = new List<TwitterStatus>();
//I am omitting the code where it fills the statues list
XmlSerializer xsSubmit = new XmlSerializer(typeof(TwitterStatus));
StringWriter sww = new StringWriter();
XmlWriter writer = XmlWriter.Create(sww);
xsSubmit.Serialize(writer, statuses);
var xml = sww.ToString();
有人能告诉我什么,我做错了什么?而不是TwitterStuts传递的类型,我应该在替代列表已经过去了?
请指教。
非常感谢
你试过传递一个列表吗?添加TwitterStatus类代码,我们可以帮助您 –