System.Invalidoperationexception

Asked

Viewed 652 times

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.

  • tried to use the .GetXml(); ? DataSet ds = new DataSet(); ds.GetXml();

  • @Rovannlinhalis same error.

  • 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

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.