System.InvalidOperationException

1

I have to convert a datatable to XML. My datatable has 68256 rows.

When I serialize to XML, I get the OutOfMemoryException: Exception_WasThrown error.

Here's the code I'm using to do 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;
    }
  }
    
asked by anonymous 04.09.2017 / 15:01

0 answers