Hi all,
I've founded some situation in which my entity object serialized to XML cannot be deserialized . It's very strange because I've serialized about 7 other object (other type objects) and everything is right for them, but still I've got one which cannot be deserialized properly.
The serialization doesn't throw any exception, but when I want to retrieve the object the following exception is throwed:
- - e {"There is an error in XML document (1605, 21)."} System.Exception {System.InvalidOperationException}
- - InnerException {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
The row and line in the exception points out the end of the XML file.
Do you have any concept, what could be wrong ?
Regards,
MiloszeS
PS. Attached is the screen shot of the watch window.
Here is the code fragment in which the object is serialized and deserialized. Maybe it will be helpful.
XmlSerializer serializer = new XmlSerializer(typeof(SomeEntity));
XmlTextWriter xmlTextWriter = new XmlTextWriter(fileName, Encoding.UTF8);
XmlTextReader xmlTextReader = null;
xmlTextWriter.Formatting = Formatting.Indented;
serializer.Serialize(xmlTextWriter, someEntity);
xmlTextWriter.Close();
xmlTextReader = new XmlTextReader(fileName);
entityToRestore = serializer.Deserialize(xmlTextReader) as SomeEntity;
xmlTextReader.Close();