C# XMLSerialize引发异常。试图序列化列表,但出现错误

C# XMLSerialize引发异常。试图序列化列表,但出现错误,c#,xml-serialization,C#,Xml Serialization,我正在尝试序列化IList集合。但它无法在代码中生成XML文档。我得到的错误是“有个问题 System.InvalidOperationException {"There was an error generating the XML document."} 这是我的密码 IList<TwitterStatus> statuses = new List<TwitterStatus>(); //I am omitting the code where it fills t

我正在尝试序列化IList集合。但它无法在代码中生成XML文档。我得到的错误是“有个问题

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();
IList status=new List();
//我省略了填充雕像列表的代码
XmlSerializer xsSubmit=新的XmlSerializer(typeof(TwitterStatus));
StringWriter sww=新StringWriter();
XmlWriter=XmlWriter.Create(sww);
xsSubmit.Serialize(编写器、状态);
var xml=sww.ToString();
有人能告诉我我做错了什么吗?我应该传递一个列表,而不是作为一种类型的推特口吃吗

请告知


非常感谢

是的,您需要传递要序列化的对象的确切类型

new XmlSerializer(typeof(List<TwitterStatus>));
新的XmlSerializer(typeof(List));

您是否尝试通过列表?添加TwitterStatus类代码,我们可以帮助您让我试试看