Catel 3.6 and ZXing.Mobile

Topics: Questions
Oct 15, 2013 at 1:02 PM
Edited Oct 15, 2013 at 1:04 PM
Hi,

I'm trying to use ZXing.Mobile https://github.com/Redth/ZXing.Net.Mobile with Catel.MVVM on my Windows Phone 8.
ZXing.Mobile uses the Deployment.Current.Dispatcher in its constructor. When I use it like this

var _scanner = new MobileBarcodeScanner(Deployment.Current.Dispatcher);
var result = await _scanner.Scan();
NavigateFarAwayWithTheResult(result);

It works.
But if I try to use it to alter a property on the current EditView,xaml. It tells me something about a NullReferenceException in ZXing.Mobile.dll and navigates back to the MainView.xaml.

var _scanner = new MobileBarcodeScanner(Deployment.Current.Dispatcher);
var result = await _scanner.Scan();
Deployment.Current.Dispatcher.BeginInvoke(() => Computer.Serial = result.Text);

I'm using it in my ViewModel : ViewModelBase

Any Idea what I'm doing wrong?
Oct 15, 2013 at 1:27 PM
Edited Oct 15, 2013 at 1:45 PM
I could do anything...it always navigates back to the MainView.xaml - even if it's executed from EditView.xaml.
It seems to have something to do with the async/await, because just executing the _scanner.Scan() Method without using the result like var result = await _scanner.Scan() is working just fine...except that I'm not getting any return ;)
Oct 15, 2013 at 3:43 PM
MobileBarcodeScanner _scanner = new MobileBarcodeScanner(DispatcherHelper.CurrentDispatcher);

var result = await _scanner.Scan();
DispatcherHelper.CurrentDispatcher.BeginInvokeIfRequired(() => Computer.InventoryNumber = result.Text);
isn't working eighter :(
Oct 15, 2013 at 3:50 PM
It's writing the result via Debug.WriteLine(result.Text)
Coordinator
Oct 16, 2013 at 6:40 PM
Edited Oct 16, 2013 at 6:40 PM
Can you provide a full repro? You can upload it here:

http://www.catelproject.com/support/issue-tracker

It can be a small application, but we are too busy to try and reproduce a problem ourselves every time.