Search Unity

Ionic.BZip2.CF (DotNetZip) assembly fails to load in WP8 using Unity 4.5.1p2

Discussion in 'Windows' started by boinged, Jun 25, 2014.

  1. boinged

    boinged

    Joined:
    May 8, 2013
    Posts:
    16
    Hi, this is working when building with Unity 4.3.4f1 but now the following exception is thrown at runtime when trying to use the assembly.

    An exception of type 'System.IO.FileLoadException' occurred in Assembly-CSharp.DLL but was not handled in user code
    Additional information: Could not load file or assembly 'Ionic.BZip2.CF, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


    The version properties in Visual Studio Express 2013 Windows shows 1.9.1.8 although inspecting the dll with ILSpy before and after processing by Unity reveals the PublicKeyToken is set to null.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    Hi,

    it is set to null with intention. However, it should also update the references in your plugin/assembly. What is referencing Ionic.BZip2CF.dll with 'PublicKeyToken=edbe51ad942a3f5c'? Is it your scripts (Assembly-CSharp.dll and the company) or some other plugin?
     
  3. boinged

    boinged

    Joined:
    May 8, 2013
    Posts:
    16
    There are two references in Assembly-CSharp to Ionic.BZip2CF, one with null public key and one with the original value. I've just reproduced this and the issue in an empty project by having some code instantiate a BZip2OutputStream.

    Example code:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using Ionic.BZip2;
    5. using System.IO;
    6.  
    7. public class BzipTest : MonoBehaviour {
    8.  
    9.     // Use this for initialization
    10.     void Start () {
    11.         byte[] bytes = new byte[10];
    12.         byte[] compressed = CompressBytes(bytes);
    13.     }
    14.  
    15.     public static byte[] CompressBytes(byte[] bytes)
    16.     {
    17.         using (MemoryStream memoryStream = new MemoryStream())
    18.         {
    19.             WriteCompressedBytes(bytes, memoryStream);
    20.            
    21.             byte[] compressedBytes = memoryStream.ToArray();
    22.             return compressedBytes;
    23.         }
    24.     }
    25.    
    26.     public static void WriteCompressedBytes(byte[] bytes, Stream toStream)
    27.     {
    28.         using (BZip2OutputStream stream = new BZip2OutputStream(toStream))
    29.         {
    30.             stream.Write(bytes, 0, bytes.Length);
    31.             stream.Flush();
    32.         }
    33.     }
    34.    
    35.     // Update is called once per frame
    36.     void Update () {
    37.    
    38.     }
    39. }
    40.  
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,675
    Now that definitely looks like a serious bug. Could you submit it? We would look into it asap.
     
  5. boinged

    boinged

    Joined:
    May 8, 2013
    Posts:
    16