We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Barcode - Object reference not set to an instance of an object.

I am creating SfBarcode generator from user input text. User choose type of code, then write text and generate it by button. Code is in attach file

1) I can´t use these characters in QRCode: š,č,ř,ž,... (diacritic) but standard qrcode and datamatrix alow these characters

2) I don't know how to write try, catch if user insert not supported characters by barcode (for now I do manually control in code)

3) 
On iOS is everything ok (work as I want), but on android i get this message:

"Object reference not set to an instance of an object."

{System.NullReferenceException: Object reference not set to an instance of an object.
  at Syncfusion.SfBarcode.XForms.Android.SfBarcodeMapping.OnSfBarcodePropertyChanged (System.String propertyName, Syncfusion.SfBarcode.XForms.SfBarcode barcode, Com.Syncfusion.Barcode.SfBarcode nativeBarcode) [0x004cb] in <e5b50884afa840daa78448e5114ae941>:0 
  at Syncfusion.SfBarcode.XForms.Android.SfBarcodeRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00014] in <e5b50884afa840daa78448e5114ae941>:0 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:150 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:370 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:623 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:417 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99 
  at Syncfusion.SfBarcode.XForms.SfBarcode.set_SymbologySettings (Syncfusion.SfBarcode.XForms.BarcodeSettings value) [0x00000] in <25124daea36445bba3d101f15dac02fc>:0 
  at Syncfusion.SfBarcode.XForms.SfBarcode.Dispose () [0x00008] in <25124daea36445bba3d101f15dac02fc>:0 
  at Syncfusion.SfBarcode.XForms.Android.SfBarcodeRenderer.Dispose () [0x00008] in <e5b50884afa840daa78448e5114ae941>:0 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.RemoveChild (Xamarin.Forms.VisualElement view) [0x00072] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:203 
  at Xamarin.Forms.Platform.Android.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00021] in D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:175 
  at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00007] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:355 
  at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:751 
  at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:461 
  at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:425 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in <3e9b3e26c4694baab3f689687ad40612>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <3e9b3e26c4694baab3f689687ad40612>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[T].RemoveItem (System.Int32 index) [0x00021] in <3e9b3e26c4694baab3f689687ad40612>:0 
  at System.Collections.ObjectModel.Collection`1[T].RemoveAt (System.Int32 index) [0x0002b] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
  at Xamarin.Forms.TemplateUtilities.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00018] in D:\a\1\s\Xamarin.Forms.Core\TemplateUtilities.cs:63 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:417 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99 
  at Xamarin.Forms.ContentView.set_Content (Xamarin.Forms.View value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\ContentView.cs:11 
  at FlowerMobileTrends.Views.PageBarcodeCreator+<OnButtonBarcodeCreate_Click>d__7.MoveNext () [0x000c0] in D:\Projekty\FlowerMobileTrends\FlowerMobileTrends\FlowerMobileTrends\Views\PageBarcodeCreator.xaml.cs:232 }


Attachment: barcode_8e457b09.zip

3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team February 18, 2019 03:35 PM UTC

Hi Tomas, 
Query 
Response 
    1)    I can´t use these characters in QRCode: š,č,ř,ž,... (diacritic) but standard qrcode and datamatrix alow these characters
     3)     On iOS is everything ok (work as I want), but on android i get this message: 
 
"Object reference not set to an instance of an object." 
 
We have tried creating QR Barcode using SfBarcode in Xamarin forms android with the inputs which you have given.  

The barcode is generated without any exception but when we tried to read the barcode using barcode scanner.  

It was not scanned properly. We have attached the sample for the same in below link. We are analyzing this issue we will let you know more about this on 20-Feb-19. 


Sample link: 


Please modify this sample with code the exceptions issue is reproduced. So that we can provide you better solution in this. 

I don't know how to write try, catch if user insert not supported characters by barcode (for now I do manually control in code) 
Since the exception is thrown while rendering we cannot implement try/catch block. But this can be achieved if there is a EventHandler triggered while saving the barcode.  

At present we do not have API for event handler while saving barcode.  

We will analyze the feasibility and let you know about this on 20-Feb-19 


Regards, 
Karthikeyan  



PV Prakash Viswanathan Syncfusion Team February 20, 2019 04:07 PM UTC

Hi Tomas, 

Thanks for the patience. 

Query 
Response 
The barcode is generated without any exception but when we tried to read the barcode using barcode scanner it was not scanned properly. 

We confirm this to be a bug and we will include the fix for this issue in our upcoming 2019 Volume 1 SP1 release. 

Since the exception is thrown while rendering we cannot implement try/catch block. But this can be achieved if there is a EventHandler triggered while saving the barcode.   
 
At present we do not have API for event handler while saving barcode.   
 
We will analyze the feasibility and let you know about this on 20-Feb-19 
We have analyzed the feasibility for implementing event handler while rendering the barcode in Xamarin platform. 

We will notify you know when this feature is implemented. 



Regards, 
Prakash V 



TT Tomas Turek February 21, 2019 12:02 PM UTC

Hi, thank you for your reply. I will look forward to a new update.

I've tried your demo, but:

1) If I use your demo with a diacritic ("š,č,ř,ž") I get the following exceptions:

Unhandled Exception:

Com.Syncfusion.Barcode.BarcodeException: Input text contains non-convertable characters
or
Com.Syncfusion.Barcode.BarcodeException: <Timeout exceeded getting exception details>


2) If I tried on iOS - QRCode is not displayed - only gray screen (on Android is everything ok)

3) I've modified your demo and added a button to change barcode. On Android: When I click the button I get the following message: (On iOS is everything OK)

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.

Attachment: sx_4824c835.zip

Loader.
Live Chat Icon For mobile
Up arrow icon