Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 703 forks source link

UWP app - .Net Native tool chain issue with Release - assembliesToInclude??? #409

Closed faceoffers28 closed 7 years ago

faceoffers28 commented 8 years ago

My app works just fine in Debug mode. When I Release the app, I can't get a couple of features to work. One of the features is the Zing.Net.Mobile.Forms. I have read that you have to inject assemblies into the Xamarin.Forms.Forms.Init method, but I can't find the correctly assemblies to add. Here is what I have tried. Does anyone know the correct combination of assemblies to include to get this to work in Release mode?

List<Assembly> assembliesToInclude = new List<Assembly>();

                assembliesToInclude.Add(typeof(ZXing.BarcodeReader).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.Reader).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.BaseLuminanceSource).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.Binarizer).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.BinaryBitmap).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.Dimension).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.LuminanceSource).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.MultiFormatReader).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.PlanarYUVLuminanceSource).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.Result).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.ResultPoint).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.RGBLuminanceSource).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(ZXing.SupportClass).GetTypeInfo().Assembly);

assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingBarcodeImageView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingScannerPage).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingScannerView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingDefaultOverlay).GetTypeInfo().Assembly);

assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScanner).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScannerBase).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScanningOptions).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.ScanPage).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScannerBase).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.SoftwareBitmapLuminanceSource).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.ZXingScannerControl).GetTypeInfo().Assembly);

 Xamarin.Forms.Forms.Init(e, assembliesToInclude);

I implemented a page like this in my PCL Project. https://github.com/Redth/ZXing.Net.Mobile/blob/master/Samples/Forms/Core/CustomScanPage.cs

Version info Install-Package ZXing.Net.Mobile -Version 2.1.44 Install-Package ZXing.Net.Mobile.Forms -Version 2.1.44

redwolf2 commented 8 years ago

Shouldn't this be enough?

assembliesToInclude.Add(typeof(ZXing.BarcodeReader).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingBarcodeImageView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScanner).GetTypeInfo().Assembly);

Look into your bin\Debug and bin\Release directory inside Visual Studio, to get an idea of what assemblies to include.

Always deinstall your App manually, when switching between Debug and Release, before you are running it.

faceoffers28 commented 8 years ago

@redwolf2 Interesting! Thanks for the hint in terms of where to look. Upon looking, I noticed that both features/packages that I'm having issues with have multiple DLLs in the Release bin. Please see attached image.

aaa4

Zxing.Net.Mobile.Core.dll Zxing.Net.Mobile.Forms.dll Zxing.Net.Mobile.Forms.WindowsUniversal.dll zxing.portable.dll ZxingNetMobile.dll

I got the scanner to work by adding these assemblies, but I can't get the text at the top or the bottom of the scanner page to appear. Any idea which assembly controls that?

assembliesToInclude.Add(typeof(ZXing.Net.Mobile.ZXing_Net_Mobile_WindowsUniversal_XamlTypeInfo.XamlMetaDataProvider).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingBarcodeImageViewRenderer).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingScannerViewRenderer).GetTypeInfo().Assembly);

I also noticed that my Windows 10 laptop scanner does not scan the barcode. I believe this has something to with a focus issue. It works fine on my Windows 10 mobile phone. I'm testing on a tablet, but I'm waiting for the app to download.

faceoffers28 commented 8 years ago

I just ran the Debug code on my Windows 10 mobile device and noticed that the top and bottom text does not display. This sound like a separate issue to me.

redwolf2 commented 8 years ago

The Top and Bottom page have their own issue entry here.

380

I don't think that problem is assembly related.

jasoncouture commented 7 years ago

You only need to refrerence assemblies with Xamarin.Forms renderers, which in this case should be only assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingBarcodeImageViewRenderer).GetTypeInfo().Assembly);

zwilkin commented 6 years ago

Shouldn't this be enough?

assembliesToInclude.Add(typeof(ZXing.BarcodeReader).GetTypeInfo().Assembly); assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingBarcodeImageView).GetTypeInfo().Assembly); assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScanner).GetTypeInfo().Assembly);

Look into your bin\Debug and bin\Release directory inside Visual Studio, to get an idea of what assemblies to include.

Always deinstall your App manually, when switching between Debug and Release, before you are running it.

Over 2 years later and this is still the way to fix.

SmartmanApps commented 5 years ago

You only need to refrerence assemblies with Xamarin.Forms renderers, which in this case should be only assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingBarcodeImageViewRenderer).GetTypeInfo().Assembly);

Yes, this proved to be sufficient to fix this issue for me. Thank you!