I have WCF Service, consumed by Silverlight client. In the service I create a string (which is representing a .csv file) and I compress it. When I try to decompress it on the client I get the following exception:
System.ArgumentException: 'iso-8859-1' is not a supported encoding name.
Parameter name: name
at System.Globalization.EncodingTable.internalGetCodePageFromName(String name)
at System.Globalization.EncodingTable.GetCodePageFromName(String name)
at System.Text.Encoding.GetEncoding(String name)
at Ionic.Zlib.GZipStream..cctor()}
I didn't manage to find any info about what is causing this and how to be avoided. I'll be grateful for any help!
The code used is the following:
Service:
private static byte[] Zip(string str)
{
var bytes = Encoding.UTF8.GetBytes(str);
using (var msInput = new MemoryStream(bytes))
using (var msOutput = new MemoryStream())
{
using (var gs = new GZipStream(msOutput, CompressionMode.Compress))
{
msInput.CopyTo(gs);
}
return msOutput.ToArray();
}
}
Silverlight client:
private void UnzipToTheExportStream(byte[] bytes)
{
using (var msi = new MemoryStream(bytes))
using (_exportStream)
{
using (var gs = new GZipStream(msi, CompressionMode.Decompress))
{
gs.CopyTo(_exportStream);
}
}
}
The exception is happening upon the initialization of the GZipStream. For decompression I use DotNetZip (Ionic.Zlib). For compression I tried both DotNetZip and System.IO.Compression (which is not available in Silverlight) but with same result
