1
I have to convert a datatable to XML. My datatable has 68256 lines.
When I serialize to XML, I get Outofmemoryexception: Exception_wasthrown error.
Follow the code I’m using to make the conversion :
var ds = new DataSet();
dtDados.TableName = "result";
ds.Tables.Add(dtDados);
using (var memoryStream = new MemoryStream())
{
using (TextWriter streamWriter = new StreamWriter(memoryStream))
{
var xmlSerializer = new XmlSerializer(typeof(DataSet));
xmlSerializer.Serialize(streamWriter, ds);
var xml = Encoding.UTF8.GetString(memoryStream.ToArray());
return xml;
}
}
You are loading something too big for the available memory.
– Maniero
tried to use the
.GetXml();
?DataSet ds = new DataSet(); ds.GetXml();
– Rovann Linhalis
@Rovannlinhalis same error.
– b3r3ch1t
unless they are very large texts, or files/images, 68k lines is very little, as bigown said, memory is missing. unfortunately I don’t know how to help you. Maybe split this data
– Rovann Linhalis