单声道& DeflateStream [英] Mono & DeflateStream

查看:120
本文介绍了单声道& DeflateStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的代码

byte[] buffer = Encoding.UTF8.GetBytes("abracadabra");
MemoryStream ms = new MemoryStream();
DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress, false);
ms.Write(buffer, 0, buffer.Length);

DeflateStream ds2 = new DeflateStream(ms, CompressionMode.Decompress, false);
byte[]  buffer2 = new byte[ms.Length];
ds2.Read(buffer2, 0, (int)ms.Length);
Console.WriteLine(Encoding.UTF8.GetString(buffer2));

从ds2中读取时,我有以下内容:

And when reading from ds2, i have the following:

Stacktrace:

Stacktrace:

at(包装器管理为本地) System.IO.Compression.DeflateStream.ReadZStream (intptr,intptr,int)< 0x00004>

at (wrapper managed-to-native) System.IO.Compression.DeflateStream.ReadZStream (intptr,intptr,int) <0x00004>

at(包装器管理为本地) System.IO.Compression.DeflateStream.ReadZStream (intptr,intptr,int)< 0x00004>

at (wrapper managed-to-native) System.IO.Compression.DeflateStream.ReadZStream (intptr,intptr,int) <0x00004>

在 System.IO.Compression.DeflateStream.ReadInternal (byte [],int,int)[0x00031]在 C:\ cygwin \ tmp \ monobuild \ build \ BUILD \ mono-2.6.3 \ mcs \ class \ System \ System.IO.Compression \ DeflateStream.cs:192

at System.IO.Compression.DeflateStream.ReadInternal (byte[],int,int) [0x00031] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:192

在 System.IO.Compression.DeflateStream.Read (byte [],int,int)[0x00086]在 C:\ cygwin \ tmp \ monobuild \ build \ BUILD \ mono-2.6.3 \ mcs \ class \ System \ System.IO.Compression \ DeflateStream.cs:214

at System.IO.Compression.DeflateStream.Read (byte[],int,int) [0x00086] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:214

在testtesttest.MainClass.Main (string [])[0x00041] in C:\ Users \ ilukyanov \ Desktop \ Cassini \ GZipDemo \ Main.cs:27

at testtesttest.MainClass.Main (string[]) [0x00041] in C:\Users\ilukyanov\Desktop\Cassini\GZipDemo\Main.cs:27

at(包装程序运行时调用) .runtime_invoke_void_object (对象,intptr,intptr,intptr)

at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr)

此应用程序已请求 运行时以异常终止它 道路.请联系应用程序的 支持团队以获取更多信息.

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

此问题出现在Mono 2.6.1&中; 2.6.3 ...

This problem appears in Mono 2.6.1 & 2.6.3...

有没有已知方法可以成功从Mono中的DeflateStream读取?也许有一些具有相同功能的第三方开源程序集?

Is there any known way to successfully read from DeflateStream in Mono? Or maybe there are some third-party open-source assemblies with the same functionality?

推荐答案

您可以使用Interop和DllImport来原生调用zlib.
如果您是在Unix平台上,唯一的技巧是在结构中使用正确的大小,并将共享库包含在LD_LIBRARY_PATH中.

You can call zlib natively using Interop with DllImport.
Only trick is to use the right size in the structures and to include the shared library in the LD_LIBRARY_PATH, if you are on a Unix platform.

这篇关于单声道&amp; DeflateStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆