Stream not readable problem

H

hs

Hi

I got a 'stream not readable' exception. I'd appreciate if some one can tell
me how i can overcome this.

thanks


My Exception
--------------
An unhandled exception of type 'System.Web.Services.Protocols.SoapException'
occurred in system.web.services.dll

Additional information: System.Web.Services.Protocols.SoapException: Server
was unable to process request. ---> System.ArgumentException: Stream was not
readable.
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean
detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(Stream stream)
at WebService1.Service1.GetCompressedData() in
c:\inetpub\wwwroot\webservice1\service1.asmx.cs:line 114
--- End of inner exception stack trace ---



My code
---------
[WebMethod]
public string GetCompressedData()
{
TextReader textreader;
DataSet ds = new DataSet();

// populate dataset
....

byte[] bytes = System.Text.Encoding.UTF8.GetBytes(ds.GetXml());

// compress using
using(MemoryStream sourcestream = new MemoryStream(bytes))
{
MemoryStream destinationStream = new MemoryStream();
using (XceedCompressedStream xcs =
new
XceedCompressedStream(destinationStream))
{
byte[] buffer = new byte[ 32768 ];
int bytesRead = 0;

while( ( bytesRead = sourcestream.Read( buffer, 0, buffer.Length ) )
{
xcs.Write( buffer, 0, bytesRead );
}
}
textreader = new StreamReader(destinationStream); // **** line 114 ****
}
return textreader.ReadToEnd();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top