2

I want to include and Barcode Reader to my UWP (C#) application. I found XZing.Net.Mobile, which build up on the XZing.Net port.

I followed the given example from the github page and modified it so that it now looks the following way:

public sealed partial class ShoppedPage : Page
{
    MobileBarcodeScanner scanner;
    public ShoppedPage()
    {
        this.InitializeComponent();
        scanner = new MobileBarcodeScanner(Dispatcher);
    }

    private void Scan_Click(object sender, RoutedEventArgs e)
    {

        //-- Config Scanner --//
        scanner.UseCustomOverlay = false;
        scanner.TopText = "Die Kamera auf den Barcode halten";
        scanner.BottomText = "Die Kamera sucht dan automatisch nach Barcodes \r\n\r\n 'Zurück' Tasten benutzen um Scannen abzubrechen";

        scanner.Scan().ContinueWith(t => HandleResult(t.Result));
    }

    private void HandleResult(ZXing.Result result)
    {
        Debug.WriteLine(result?.Text);
    }

}

Now I keep running into the following Exception:

Message : {"Object reference not set to an instance of an object."}

Source : "ZXingNetMobile"

StackTrace : at ZXing.Mobile.ZXingScannerControl.d__13.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at ZXing.Mobile.ScanPage.d__73.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)\r\n at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()

Now my question is did I set up the Libary wrong or used in a wrong way? Maybe is there something I oversee ? Or is there a better C# Uwp friendly Barcode Reader Library which is free to use out there?

Templum
  • 183
  • 1
  • 12
  • The other nullpointer question doesnt solve my problem. Its more based on the library itself or maybe my usages of the library. All things haven initilised properly, which is observable in the stacktrace. Because the error was not thrown in my code. @Steve – Templum Feb 10 '16 at 16:02

0 Answers0