I have an object in c# that needs to be saved as file and reused.
So basically what I am doing now is I am serializing a class to xml and I am saving it as a file. The file is aproximatelly 100MB.
Now the problem I am experiencing is when I want to deserialize file to class, I and up with OutOfMemoryException.
I am using the following code:
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(file);
Deserialize<T>(xmlDocument.InnerXml);
public static T Deserialize<T>(string xmlContent)
{
var inStream = new StringReader(xmlContent);
var ser = new XmlSerializer(typeof(T));
return (T)ser.Deserialize(inStream);
}
xmlDocument.InnerXml, that seems odd.