Serialization problem
-
I have a very simple and short application, which is copy/pasted below. Serialization goes perfectly nice. The XML file is being created and it looks correct. The problem starts when trying to deserialize -> I get an error: Code: There is an error in XML document (1, 1). --------------------------------- This is the programme:
[Serializable] publicclassData { [XmlArrayItem(typeof(string))] publicArrayList Pol = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Eng = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Ger = newArrayList(); }
[Serializable] publicclassStoreHouse { [XmlArrayItem(typeof(Data))] publicArrayList DataList = newArrayList(); }
Serialization part:Data d = newData(); d.Eng.Add("1"); d.Eng.Add("2"); d.Ger.Add("dadas"); d.Ger.Add("dsadsadAS"); d.Pol.Add("dasd"); d.Pol.Add("etrre"); d.Pol.Add("trtre"); sh.DataList.Add(d); Data d1 = newData(); d1.Eng.Add("1321"); d1.Eng.Add("2ds"); d1.Ger.Add("ddadadas"); d1.Ger.Add("dsa123123dsadAS"); d1.Pol.Add("das31231dasd"); d1.Pol.Add("et3213rre"); d1.Pol.Add("t131rtre"); sh.DataList.Add(d1); XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); s.Serialize(new System.IO.StreamWriter(@"c:\a.xml"), sh);
Deserialization part:XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); sh = ((StoreHouse)s.Deserialize(new System.IO.StringReader(@"c:\a.xml")));
What do you think may be wrong? thank you very much in advance -
I have a very simple and short application, which is copy/pasted below. Serialization goes perfectly nice. The XML file is being created and it looks correct. The problem starts when trying to deserialize -> I get an error: Code: There is an error in XML document (1, 1). --------------------------------- This is the programme:
[Serializable] publicclassData { [XmlArrayItem(typeof(string))] publicArrayList Pol = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Eng = newArrayList(); [XmlArrayItem(typeof(string))] publicArrayList Ger = newArrayList(); }
[Serializable] publicclassStoreHouse { [XmlArrayItem(typeof(Data))] publicArrayList DataList = newArrayList(); }
Serialization part:Data d = newData(); d.Eng.Add("1"); d.Eng.Add("2"); d.Ger.Add("dadas"); d.Ger.Add("dsadsadAS"); d.Pol.Add("dasd"); d.Pol.Add("etrre"); d.Pol.Add("trtre"); sh.DataList.Add(d); Data d1 = newData(); d1.Eng.Add("1321"); d1.Eng.Add("2ds"); d1.Ger.Add("ddadadas"); d1.Ger.Add("dsa123123dsadAS"); d1.Pol.Add("das31231dasd"); d1.Pol.Add("et3213rre"); d1.Pol.Add("t131rtre"); sh.DataList.Add(d1); XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); s.Serialize(new System.IO.StreamWriter(@"c:\a.xml"), sh);
Deserialization part:XmlSerializer s = newXmlSerializer(typeof(StoreHouse)); sh = ((StoreHouse)s.Deserialize(new System.IO.StringReader(@"c:\a.xml")));
What do you think may be wrong? thank you very much in advance -
I read many MSDN articles regarding serialization issue. I still can`t see mistake. Can you?
-Yoyosh- wrote:
I read many MSDN articles
I don't care how many you read did you read the "one" that I pointed you to? The first one in the search results using my search? Did you read the section titled "Problems Deserializing XML"? If you did all that why have you not posted the contents of the InnerException so we can help you?
led mike