473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Serailizing to a MemoryStream

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
Nov 15 '05 #1
4 6939
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 Brewerton" <as****@brewerton.net> wrote in message
news:bf**********@lust.ihug.co.nz...
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

Nov 15 '05 #2
Ashley Brewerton wrote:
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

Nov 15 '05 #3
Thanks Andreas. Now resolved.

Ashley
"Andreas Huber" <ah****@gmx.net> wrote in message
news:3f******@news.swissonline.ch...
Ashley Brewerton wrote:
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

Nov 15 '05 #4
Just guessing: Have you forgotten to reset MemoryStream.Position before
calling ReadXml()?
Yes, thank you. I couldn't figure this out for the longest time... the stream was the right length, but always returning 0s. I couldn't find any well-written documentation for the MemoryStream object... or at least none that I could stand to sift through. This worked perfectly, though.
Jul 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: xmlguy | last post by:
PREVIOUS BACKGROUND POST: I am trying to reuse a Memory Stream for loading and transforming the xml it contains Basically I have defined following interfaces: Class Render {
3
by: Nicolas | last post by:
Hi Everybody, I'm working with the MemoryStream and I'm having problems with the ReadBytes method. When I use it, this method never returns bytes!!!! MemoryStream sw = new MemoryStream();...
2
by: SQLScott | last post by:
For some reason I am drawing a blank on this, so I would be extremely greatful if someone could help me out. I am trying to get a MemoryStream out of a Byte array. How do I get it back out? ...
13
by: Don | last post by:
When I run the following code, the MemoryStream's Position is always set to 762 instead of 0, which is what I would expect: Dim bmp As Image Dim ms As MemoryStream bmp = New...
10
by: Asaf | last post by:
Hi, I am trying to Compress & Decompress a DataSet. When running this code I am receiving the error: System.Xml.XmlException was unhandled Message="Root element is missing."...
4
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
4
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3)...
3
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I am using dotnet remoting with a binarry formatter. I have a property that returns a memorystream that has had a file loaded into it. When I try to access this property though I get an...
3
by: =?Utf-8?B?VmljdG9y?= | last post by:
Hi, Could you tell me can I keep the MemoryStream open and "close" the BinaryReader? As the MemoryStream is used for buffering the TCP data and BinaryReader is only used to read the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.