Gets or sets the code that caused the exception.
Syntax
Return Value
The exception code.
Example
Visual Basic | Copy Code |
---|
Private Sub CodeExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "barcode1.tif")
BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d)
Dim barEngine As BarcodeEngine = New BarcodeEngine()
Dim searchRect As Rectangle = New Rectangle(0, 0, 0, 0)
Dim bar1d As Barcode1d = New Barcode1d()
bar1d.Direction = BarcodeDirectionFlags.LeftToRight
bar1d.Granularity = 9
bar1d.MaximumLength = 3
bar1d.MinimumLength = 1
Try
barEngine.Read(image, searchRect, BarcodeSearchTypeFlags.Barcode1dEan13, BarcodeUnit.ScanlinesPerPixels, BarcodeReadFlags.BlockSearch Or BarcodeReadFlags.Markers, 0, bar1d, Nothing, Nothing)
BarcodeEngine.Shutdown()
Catch ex As BarcodeException
If ex.Code = BarcodeExceptionCode.Barcode1dLocked Then
MessageBox.Show("You need to unlock barcode linear engine")
Else
MessageBox.Show(String.Format("Could not read barcodes, Leadtools code: {0}" & Constants.vbLf & "Message: {1}", ex.Code, ex.Message))
End If
Catch ex As Exception
MessageBox.Show(String.Format("Could not read barcodes {0}", ex.Message))
End Try
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
private void CodeExample() { // Load an image RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; string fileName = LeadtoolsExamples.Common.ImagesPath.Path + "barcode1.tif"; RasterImage image = codecs.Load(fileName); // Initialize linear barcodes BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d); BarcodeEngine barEngine = new BarcodeEngine(); Rectangle searchRect = new Rectangle(0, 0, 0, 0); Barcode1d bar1d = new Barcode1d(); bar1d.Direction = BarcodeDirectionFlags.LeftToRight; bar1d.Granularity = 9; bar1d.MaximumLength = 3; bar1d.MinimumLength = 1; try { // Try to read barcodes barEngine.Read(image, searchRect, BarcodeSearchTypeFlags.Barcode1dEan13, BarcodeUnit.ScanlinesPerPixels, BarcodeReadFlags.BlockSearch | BarcodeReadFlags.Markers, 0, bar1d, null, null); BarcodeEngine.Shutdown(); } catch (BarcodeException ex) { // See if LEADTOOLS could not recognize this image format if (ex.Code == BarcodeExceptionCode.Barcode1dLocked) MessageBox.Show("You need to unlock barcode linear engine"); else { // Other LEADTOOLS Barcode error MessageBox.Show(string.Format("Could not read barcodes, Leadtools code: {0}\nMessage: {1}", ex.Code, ex.Message)); } } catch (Exception ex) { // Other errors MessageBox.Show(string.Format("Could not read barcodes {0}", ex.Message)); } RasterCodecs.Shutdown(); } |
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also