DllNotFoundException: MonoPosixHelperSystem.IO.Compression.DeflateStream
Asked Answered
B

2

0

Can anybody help out with this error? I'm not new to .net, but very new to Mono.

Full error message:

DllNotFoundException: MonoPosixHelper
System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) 
(wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode,bool,bool)
System.IO.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen) 
System.IO.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode) 
(wrapper remoting-invoke-with-check) System.IO.Compression.GZipStream:.ctor (System.IO.Stream,System.IO.Compression.CompressionMode)
Demeter.Zipper.Decompress (System.IO.Stream source, System.IO.Stream destination) 
Demeter.DataArchive.GetItemFromArchive[StringLibrary] (System.String folder, System.String fileName) [0x00000]
TestScript.Start ()   (at Assets\Scripts\TestScript.cs:29)

I'm definitely targeting Windows for my app and hoping to target Macs.

Here's my nifty Zipper class:

/// /// Simple stream compression utlity class /// Source: http://blogs.msdn.com/bclteam/archive/2005/06/15/429542.aspx ///

public static class Zipper
{
    /// <summary>
    /// Compress the source stream to the destination
    /// </summary>
    /// <param name="source"></param>
    /// <param name="destination"></param>
    public static void Compress(Stream source, Stream destination)
    {
        // We must explicitly close the output stream, or GZipStream will not
        // write the compression's footer to the file.  So we'll get a file, but
        // we won't be able to decompress it.  We'll get back 0 bytes.
        using (GZipStream output = new GZipStream(destination, CompressionMode.Compress))
        {
            Pump(source, output);
        }
    }

/// <summary>
/// Decompress the source stream to the destination
/// </summary>
/// <param name="source"></param>
/// <param name="destination"></param>
public static void Decompress(Stream source, Stream destination)
{
    using (GZipStream input = new GZipStream(source, CompressionMode.Decompress))
    {
        Pump(input, destination);
    }
}

/// <summary>
/// private buffer pumper to shove one stream into another
/// </summary>
/// <param name="input"></param>
/// <param name="output"></param>
private static void Pump(Stream input, Stream output)
{
    byte[] bytes = new byte[4096];
    int n;
    while ((n = input.Read(bytes, 0, bytes.Length)) != 0)
    {
        output.Write(bytes, 0, n);
    }
}

}

Bioplasm answered 6/6, 2023 at 1:54 Comment(0)
E
0

After further inspection, the reason for this failure is not so much the old mono version shipped with Unity 2.6.1, but rather that Mono implements System.IO.Compression.GZipStream not with a managed implementation, but it relies on a system installed zlib instead.

As it's not a good idea for Unity games to rely on the presence of zlib, it's a much safer idea to use a fully managed implementation instead.

If you have trouble getting a 3rd party managed implementation of compression to work, please open a new question, and I'll take a look at that too.

Earthworm answered 6/6, 2023 at 1:12 Comment(1)

Thanks for the deep research, Lucas. I have asked the follow up question here: http://answers.unity3d.com/questions/10650/whats-the-best-way-to-implement-file-compression

Bioplasm
B
0

Searching the Unity forums, I found out that the version of mono used by Unity is out of date and the Unity team is working to update the engine with the newest mono libraries. This would solve this problem.

There are a couple immediate solutions. Some have reported that DotNetZip works with Unity. I keep receiving an "IBM437 codepage not supported" (or similar) error when trying to work with this library. It is a much better library than SharpZipLib from a usability perspective.

The article linked by drozzy has a mono compiled version of SharpZipLib, which seems like the way to go. I would prefer to use DotNetZip and not rely on a community-compiled version of a different library.

Thoughts?

Bioplasm answered 6/6, 2023 at 1:1 Comment(1)

This is indeed caused by Unity2.6's relatively old mono version. I'll take a look at how easy/hard it is to get GZipStream working out of the box. In the meantime, using a third party managed compression library seems like the most viable option.

Earthworm
E
0

After further inspection, the reason for this failure is not so much the old mono version shipped with Unity 2.6.1, but rather that Mono implements System.IO.Compression.GZipStream not with a managed implementation, but it relies on a system installed zlib instead.

As it's not a good idea for Unity games to rely on the presence of zlib, it's a much safer idea to use a fully managed implementation instead.

If you have trouble getting a 3rd party managed implementation of compression to work, please open a new question, and I'll take a look at that too.

Earthworm answered 6/6, 2023 at 1:12 Comment(1)

Thanks for the deep research, Lucas. I have asked the follow up question here: http://answers.unity3d.com/questions/10650/whats-the-best-way-to-implement-file-compression

Bioplasm

© 2022 - 2024 — McMap. All rights reserved.