Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Decompress error (Compressed using gzipStream)
posted

Hi,
   I am trying to decompress a compressed string in the Sliverlight side using zlibStream and getting exception.
Compressed string is generated from .NET's gzipStream class(WCF server side) and zLibStream is used to uncompressed the string.
Below is the detailed exception and functions used in Silverlight to decompress and function used in WCF side to compress the string.
Question is can zlibStream can uncompresss strings created using gZipStream? if yes, why I am getting following exection.


Exception Information:
Message : "Bad state (unknown compression Method (0x1F))"
Stack:
at h6.a(FlushType A_0)
at Infragistics.Silverlight.Compression.ZlibCodec.Inflate(FlushType flush)
at jm.b(Byte[] A_0, Int32 A_1, Int32 A_2)
at Infragistics.Silverlight.Compression.ZlibStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()


Here are functions for decompress/compression:

Decompress Function on SilverLight side:
private string UnzipString(string compressedStr)
{
    using (MemoryStream ms = new MemoryStream(System.Convert.FromBase64String(compressedStr)))
    {
        using (ZlibStream zStream = new ZlibStream(ms, CompressionMode.Decompress))
        {
            StreamReader streamReader = new StreamReader(zStream);
            return streamReader.ReadToEnd();
        }
    }
}
 

//Compress function on the WCF (.NET) side
public string CompressedString(string data)
{
    using (MemoryStream memoryStream = new MemoryStream())
    {
        using (GZipStream compressedZipStream = new GZipStream(memoryStream, CompressionMode.Compress))
        {
            byte[] byteData = Encoding.ASCII.GetBytes(data);
            compressedZipStream.Write(byteData, 0, byteData.Length);
        }
        return Convert.ToBase64String(memoryStream.ToArray());
    }
}

 

Parents
No Data
Reply Children
No Data