Serailizing to a MemoryStream

  • Thread starter Thread starter Ashley Brewerton
  • Start date Start date
A

Ashley Brewerton

When I use the DataSet.WriteXml using a XmlTextWriter to a MemoryStream,
when I try to read the stream back into a DatasSet using ReadXml I get an
error indicating the root not is not avaialable. However if I write from
the MemoryStream to a file then read the file into a DataSet it works as it
should.

Couldn't find any reference to this onMSDN or the usual C# sites.

Thanks.

Ashleyb
 
I can tell you the same. I could not solve this problem about 2-3 months ago
and even write about the same problem here. I refused at that stage.

When you try to save some intermediate information to a file you can find a
difference, sounds like the memory stream was not flashed, did not read the
stream to the very end etc. I assume that it's a bug. If you can find a
solution please let me know.

Dmitri.
 
Ashley said:
When I use the DataSet.WriteXml using a XmlTextWriter to a
MemoryStream, when I try to read the stream back into a DatasSet
using ReadXml I get an error indicating the root not is not
avaialable. However if I write from the MemoryStream to a file then
read the file into a DataSet it works as it should.

Just guessing: Have you forgotten to reset MemoryStream.Position before
calling ReadXml()?

Regards,

Andreas
 
Thanks Andreas. Now resolved.

Ashley


Andreas Huber said:
Just guessing: Have you forgotten to reset MemoryStream.Position before
calling ReadXml()?

Regards,

Andreas
 
Back
Top