Search code examples
unity-game-enginezxinghololens

Using ZXing with Hololens


I've been trying to use Zxing on the Hololens but as soon as the app starts on the device, I get a fileloadException when this line is called:

BarcodeReader barcodeReader = new BarcodeReader();

FileLoadException: Could not load file or assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at ZXing.BarcodeReader..ctor() at Decoder.Start() at Decoder.$Invoke1(Int64 instance, Int64 args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64 args, IntPtr method) (Filename: Line: 0).

I have the Unity 2018.1.0b5 beta version with Visual Studio 2017 on Windows 10.
The Building works perfectly so the library is found.

Here's how I import ZXing library :

Project Folder

I've read all the other topics I found on it but the solutions provided do not work. I also tried to use the Zxing.winmd but the dll can't be found then.

Did I miss a step ? A file to download maybe ?

Thanks for your help !


Solution

  • After many configurations tried, I finally managed to use Zxing on Hololens by switching the scripting Backend in Player Settings to Il2Cpp. I was using .net (for the scripting backend) which caused me most of the errors. Il2CPP

    If you don't have the IlCPP proposition, you might need to relaunch the Unity installer, making sure that "Windows Store Il2CPP " is checked.installation

    I also downgraded my version of unity to 2017 in order to use the Holotoolkit which wasn't working on my 2018 beta version.

    This way I don't need any specific settings to import Zxing in the Assets. Also, I didn't use Zxing.winmd but Zxing.unity.

    settings Zxing

    Tips : don't forget to unable the webcam and to deploy it in Visual Studio with "Release", otherwise it's going to slow down your app. If Visual Studio doesn't find your Zxing.unity file, right click on your project in the Solution's Explorer (of Visual Studio) : Add->Reference->Find your Zxing.unity.