ZXing.Net into standard .net 2.0 library and Xamarin application

JeromeGodboutAmotusJeromeGodboutAmotus Member ✭✭
edited January 28 in Xamarin.Forms

Hi,
I'm new to Xamarin and this whole .NET, I,m starting a new project and I was creating .NET library 2.0 to put the commun code. I have a need to extract multiple barcode from an image and was using ZXing as demo on Window with full .NET Framework 4.7. Now I would like to port this to Xamarin and I'm having some trouble to integrate it into my library. Here's my project structure:

  • GF-Trace.Android (Xamarin Android)

    • Reference to:
      • GF-Trace
      • NuGet packages:
      • Xamarin.Forms
      • ZXing.Net
        * Android.*
  • GF-Trace (.Net Standard 2.0 lib)

    • Build Dependencies:

      • GF-Imaging
    • NuGet packages:

      • Xamarin.Forms
      • ZXing.Net
  • GF-Imaging (.Net Standard 2.0 lib)

    • NuGet packages:
      • Xamarin.Forms
      • ZXing.Net

I have some hard time to make it work properly. The compiler complain about missing reference.

Severity    Code    Description Project File    Line    Suppression State
Error       Can not resolve reference: `zxing`, referenced by `GF-Trace`. Please add a NuGet package or assembly reference for `zxing`, or remove the reference to `GF-Trace`.  GF-Trace.Android        

Under UWP, it does compile but when running I get a method missing exception error:

System.MissingMethodException
  Message=Method not found: 'ZXing.Result[] ZXing.BarcodeReader.DecodeMultiple(Byte[])'.
  Source=GF-Trace
  StackTrace:
   at GF_Trace.Views.XyMeasurementPage.ExtractQRCodeMessageFromImage(Byte[] bitmap) in ...\GF-Trace\GF-Trace\Views\Debug\XyMeasurementPage.xaml.cs:line 128
...

So I wonder how I should be doing this? GF-Imaging is a reusable lib that implement function to manipulate images and could do some processing to recover barcode with ZXing. GF-Trace is the common application library that also can use some ZXing types. GF-Trace.Android or GF-Trace.UWP consume the GF-Trace.

The ZXing.Net said it support .Net Standard 2.0 and Xamarin.Android. What is wrong or how does one ensure the function and lib are present for a given platform?

NOTE I did select ZXing.Net and not the mobile version because the image can come from different source and not only from the camera as stand still image. So I tried to avoid the ZXing.Net.Mobile which wrap all into a Form GUI.

Thanks, Maybe I'm doing something wrong into my setup, but I have no clue why it doesn't found the lib or the methods.

Answers

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai
    edited January 28

    ZXing.Net into standard .net 2.0 library and Xamarin application

    You could try using the ZXing.Net.Mobile library instead: https://github.com/Redth/ZXing.Net.Mobile

    ZXing.Net.Mobile is a C#/.NET library based on the open source Barcode Library: ZXing (Zebra Crossing), using the ZXing.Net Port. It works with Xamarin.iOS, Xamarin.Android, and Windows Phone. The goal of ZXing.Net.Mobile is to make scanning barcodes as effortless and painless as possible in your own applications. The new iOS7 AVCaptureSession barcode scanning is now also supported!

  • Yeah, this is what we did end up doing, but we still don't understand the problem with ZXing.Net in the first place? is this whole NuGet a big mess with supported assembly?
    As for Mbile, at least the underlayer is still available since I I have zero used for the camera access form. I still find this whole self proclaim .NET standard 2.0 packages a huge mess, some only stub, some doesn't even work on some assembly. This is missleading and a huge waist of time.

    I will stick with Qt when I'm not force on Xamarin, seriously, they need to find a better way.

Sign In or Register to comment.