单声道放气流 [英] Mono & DeflateStream

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

问题描述

我有一个简单的代码

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:

堆栈跟踪:

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] 在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.

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

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