We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NullReference Exception during barcode recognition


I came across an issue with barcode recognition using Aspose.BarCodeRecognition library. I have a code (see vb.net example below) that is iterating through a TIFF image frames and recognizing barcodes (QR codes actually) on every frame. Usually it works fine, but sometimes it fails with the NullReference exception below.

What is very unpleasant is that it makes the application to crash completely, try-catch block does not help. The exception below has been retrieved from the system windows application log.

Any experience or help with this is welcome!


Jiri Matejka

Code (simplified):
'Bitmap is a System.Drawing.Image instnance

Dim rd As Aspose.BarCodeRecognition.BarCodeReader = Nothing
rd = New Aspose.BarCodeRecognition.BarCodeReader(Bitmap, ReadType)
rd.Timeout = 2500
rd.SetHints(RecognitionHints.ImageBinarizationHints.MedianSmoothing Or
RecognitionHints.ImageBinarizationHints.Grayscale Or
Success = rd.Read()
Catch ex As System.Exception
’ exception is logged here
Return False
End Try

Dim CodeText As String
CodeText = rd.GetCodeText
Catch ex As Exception
return False
’ exception logged here
End Try

Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at Aspose.BarCodeRecognition.٪.ڣ(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading._TimerCallback.PerformTimerCallback(System.Object)

Hi Jiri,

Thanks for your inquiry. First off, please note that each new release contains many improvements, bug fixes and new features. So, we suggest you always use the latest version of Aspose products because I can see that you are using an old version of Aspose.BarCode for .NET. The SetHints method has been obsoleted.

Could you please try the latest version of Aspose.BarCode product? Also, please let us know how it goes on your side. You can download it from here: http://www.aspose.com/community/files/51/.net-components/aspose.barcode-for-.net/default.aspx

It would be great, if you can share problematic barcode images here in this thread. We will take a closer look and guide you accordingly. In addition, there are some evaluation limitations. You can avoid evaluation limitations by getting a temporary license for 30 days and try the latest version at your end.

You can learn all about how Aspose products are licensed by checking out the Licenses FAQ here: http://www.aspose.com/corporate/purchase/faqs/default.aspx

I hope this will help you.

Hi Imran,

thanks for your reply. Yeah, we are using 3.6.1 version, will try out the latest version.

Unfortunately it does not happen always but just interminenttly, also hardly reproducible on our Dev environment. This issue has been raised by our client.

I also figured out that this error occured when reading a page with NO barcodes. Actually we are looking for barcodes on multiple pages (cca 10-100) and usually just one or two contains a barcode.


Hi Jiri,

Thanks for the information. Yes, please try it with the latest version of Aspose.BarCode for .NET or share the problematic barcode image. We will try it on our side. Also, there is a big difference between Aspose.BarCode 3.6.0 and the latest one because these two versions are separated by years, even not months.