I want to Serialize a 60mb file into XML but it gives me System out of memory exception.
Did any one else had this kind of problem?
Can someone suggest me a workaround for this problem.
Here is the method
static public string Serialize(object obj)
{
string returnValue;
System.Xml.Serialization.XmlSerializer xmlWriter = new System.Xml.Serialization.XmlSerializer(obj.GetType());
System.IO.StringWriter xmlOut = new System.IO.StringWriter();
//this is where the problem is.....
xmlWriter.Serialize(xmlOut, obj);
//return the Serialized XML
returnValue = xmlOut.ToString();
xmlOut.Close();
return returnValue;
}
With a stream that large, I think you should consider serializing to a file first. Serializing takes a lot of memory, and doing so purely in memory is killing you.