单声道和放气流
我有一个简单的代码
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 读取时,我有以下内容:
堆栈跟踪:
at(包装器托管到本机) 系统.IO.压缩.DeflateStream.ReadZStream (intptr,intptr,int) <0x00004>
at(包装器托管到本机) 系统.IO.压缩.DeflateStream.ReadZStream (intptr,intptr,int) <0x00004>
在 System.IO.Compression.DeflateStream.ReadInternal (字节[],int,int) [0x00031] 中 C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:192
在 System.IO. Compression.DeflateStream.Read (字节[],int,int) [0x00086] 在 C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:214
在 testtesttest.MainClass.Main (字符串[]) [0x00041] 在 C:\Users\ilukyanov\Desktop\Cassini\GZipDemo\Main.cs:27
at(包装运行时调用) .runtime_invoke_void_object (对象,intptr,intptr,intptr)
此应用程序已请求 运行时以异常方式终止它 方式。请联系应用程序 支持团队了解更多信息。
此问题出现在 Mono 2.6.1 和 Mono 2.6.1 中。 2.6.3...
是否有任何已知的方法可以在 Mono 中成功读取 DeflateStream?或者也许有一些具有相同功能的第三方开源程序集?
I have a simple code
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));
And when reading from ds2, i have the following:
Stacktrace:
at (wrapper managed-to-native)
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.ReadInternal
(byte[],int,int) [0x00031] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-2.6.3\mcs\class\System\System.IO.Compression\DeflateStream.cs:192at
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:214at testtesttest.MainClass.Main
(string[]) [0x00041] in
C:\Users\ilukyanov\Desktop\Cassini\GZipDemo\Main.cs:27at (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.
This problem appears in Mono 2.6.1 & 2.6.3...
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Interop 和 DllImport 来本地调用 zlib。
唯一的技巧是在结构中使用正确的大小,并将共享库包含在 LD_LIBRARY_PATH 中(如果您使用的是 Unix 平台)。
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.
请提交针对 Mono 的错误。如果您这样做,它可能会在 2.6.4 中及时得到修复。
Please file a bug against Mono. If you do so, it might get fixed in time for 2.6.4.