Skip to content

Infragistics Community Forum / Cross Platform / Ultimate UI for Xamarin / Decompress error (Compressed using gzipStream)

Decompress error (Compressed using gzipStream)

New Discussion
Jigar Patel
Jigar Patel asked on Jul 12, 2010 2:01 PM

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());
}
}

 

Sign In to post a reply

Replies

  • 0
    Konstantin Koynov
    Konstantin Koynov answered on Jul 12, 2010 2:01 PM

    Hi jpatel0,

    Silverlight Compression Library supports only these two compression algorithms:

    • DEFLATE
    • ZLib

    As you can see GZIP is not supported. That is the reason you can not decompress GZIP compressed string.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Jigar Patel
Favorites
0
Replies
1
Created On
Jul 12, 2010
Last Post
16 years, 2 months ago

Suggested Discussions

Tags

No tags

Created by

Created on

Jul 12, 2010 2:01 PM

Last activity on

Feb 18, 2026 7:56 AM