Gets or sets the code that caused the exception.
Syntax
Property Value
The exception code.
Example
Visual Basic | Copy Code |
---|
Public Sub CodeExample()
' Load an image
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif"))
' Initialize barcodes
Dim barEngine As BarcodeEngine = New BarcodeEngine()
Dim searchRect As LeadRect = LeadRect.Empty
Dim bar1d As Barcode1d = 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 Or BarcodeReadFlags.Markers, 0, bar1d, Nothing, Nothing)
Catch ex As BarcodeException
' See if LEADTOOLS could not recognize this image format
If ex.Code = BarcodeExceptionCode.Barcode1dLocked Then
Console.WriteLine("You need to unlock barcode linear engine")
Else
' Other LEADTOOLS Barcode error
Console.WriteLine("Could not read barcodes, Leadtools code: {0}" & Constants.vbLf & "Message: {1}", ex.Code, ex.Message)
End If
Catch ex As Exception
' Other errors
Console.WriteLine("Could not read barcodes {0}", ex.Message)
End Try
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class |
C# | Copy Code |
---|
public void CodeExample()
{
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
string fileName = Path.Combine(LEAD_VARS.ImagesDir, "barcode1.tif");
RasterImage image = codecs.Load(fileName);
// Initialize barcodes
BarcodeEngine barEngine = new BarcodeEngine();
LeadRect searchRect = LeadRect.Empty;
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);
}
catch (BarcodeException ex)
{
// See if LEADTOOLS could not recognize this image format
if (ex.Code == BarcodeExceptionCode.Barcode1dLocked)
Console.WriteLine("You need to unlock barcode linear engine");
else
{
// Other LEADTOOLS Barcode error
Console.WriteLine("Could not read barcodes, Leadtools code: {0}\nMessage: {1}", ex.Code, ex.Message);
}
}
catch (Exception ex)
{
// Other errors
Console.WriteLine("Could not read barcodes {0}", ex.Message);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
} |
SilverlightCSharp | Copy Code |
---|
public void CodeExample(RasterImage image)
{
// Initialize barcodes
BarcodeEngine barEngine = new BarcodeEngine();
LeadRect searchRect = LeadRect.Empty;
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);
}
catch (BarcodeException ex)
{
// See if LEADTOOLS could not recognize this image format
if (ex.Code == BarcodeExceptionCode.Barcode1dLocked)
Console.WriteLine("You need to unlock barcode linear engine");
else
{
// Other LEADTOOLS Barcode error
Console.WriteLine("Could not read barcodes, Leadtools code: {0}\nMessage: {1}", ex.Code, ex.Message);
}
}
catch (Exception ex)
{
// Other errors
Console.WriteLine("Could not read barcodes {0}", ex.Message);
}
} |
SilverlightVB | Copy Code |
---|
Public Sub CodeExample(ByVal image As RasterImage)
' Initialize barcodes
Dim barEngine As BarcodeEngine = New BarcodeEngine()
Dim searchRect As LeadRect = LeadRect.Empty
Dim bar1d As Barcode1d = 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 Or BarcodeReadFlags.Markers, 0, bar1d, Nothing, Nothing)
Catch ex As BarcodeException
' See if LEADTOOLS could not recognize this image format
If ex.Code = BarcodeExceptionCode.Barcode1dLocked Then
Console.WriteLine("You need to unlock barcode linear engine")
Else
' Other LEADTOOLS Barcode error
Console.WriteLine("Could not read barcodes, Leadtools code: {0}" & Constants.vbLf & "Message: {1}", ex.Code, ex.Message)
End If
Catch ex As Exception
' Other errors
Console.WriteLine("Could not read barcodes {0}", ex.Message)
End Try
End Sub |
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7
See Also