Fehlerbehandlung und Debugging bei der Barcode-Verarbeitung in C#
Fehler in Pipelines zur Barcode-Verarbeitung können unbemerkt bleiben. Ein leeres Ergebnis wird oft fälschlich als „kein Barcode vorhanden“ interpretiert, obwohl auch beschädigte Dateien, passwortgeschützte PDFs oder abweichende Formate die Ursache sein können. Mit Protokollierung und strukturierter Fehlerbehandlung können Sie solche Fehler erkennen und gezielt untersuchen.
IronBarcode bietet eine Hierarchie von Ausnahmetypen im Namespace IronBarCode.Exceptions, eine integrierte Protokollierungs-API und detaillierte BarcodeResult-Eigenschaften. Sie liefern für jeden erfolgreich decodierten Barcode das erkannte Format, den decodierten Wert, die Seitennummer und die Koordinaten.
Diese Anleitung zeigt, wie Sie typisierte Ausnahmen abfangen und auswerten, fehlgeschlagene Lesevorgänge untersuchen, strukturierte Protokollierung aktivieren und Fehler bei der Stapelverarbeitung auf einzelne Dateien eingrenzen.
Schnellstart: Barcode-Fehler behandeln und Diagnose aktivierenFangen Sie bei Lese- und Schreibaufrufen gezielt die typisierten Ausnahmen von IronBarcode in try-catch-Blöcken ab. So erhalten Sie aussagekräftige Fehlermeldungen und können die Ursachen beheben.
-
1Installieren Sie IronBarcode mit NuGet Package Manager
-
2Kopieren Sie diesen Codeausschnitt und führen Sie ihn aus.
using IronBarCode; using IronBarCode.Exceptions; try { BarcodeResults results = BarcodeReader.Read("label.pdf"); Console.WriteLine($"Found {results.Count} barcode(s)"); } catch (IronBarCodeFileException ex) { Console.Error.WriteLine($"File error: {ex.Message}"); }Imports IronBarCode Imports IronBarCode.Exceptions Try Dim results As BarcodeResults = BarcodeReader.Read("label.pdf") Console.WriteLine($"Found {results.Count} barcode(s)") Catch ex As IronBarCodeFileException Console.Error.WriteLine($"File error: {ex.Message}") End TryImports IronBarCode Imports IronBarCode.Exceptions Try Dim results As BarcodeResults = BarcodeReader.Read("label.pdf") Console.WriteLine($"Found {results.Count} barcode(s)") Catch ex As IronBarCodeFileException Console.Error.WriteLine($"File error: {ex.Message}") End Try -
3Bereitstellen zum Testen in Ihrer Live-Umgebung
Beginnen Sie noch heute, IronBarcode in Ihrem Projekt mit einer kostenlosen Testversion zu verwenden
Fehler bei der Barcode-Verarbeitung behandeln und Diagnose mit IronBarcode aktivieren
- Laden Sie die IronBarcode-Bibliothek von NuGet herunter
- Fangen Sie bei Lese- und Schreibaufrufen bestimmte Ausnahmetypen in try-catch-Blöcken ab.
- Prüfen Sie
BarcodeResultsnach einem erfolgreichen Lesevorgang auf leere Einträge oder Einträge mit geringer Zuverlässigkeit. - Aktivieren Sie
IronSoftware.Logger, um interne Diagnoseausgaben zu erfassen. - Behandeln Sie bei der Stapelverarbeitung Fehler pro Datei und setzen Sie die Verarbeitung mit der nächsten Datei fort.
Wie fange ich Ausnahmen von IronBarcode ab und werte sie aus?
Fangen Sie Ausnahmen von IronBarcode in der Reihenfolge vom spezifischsten bis zum allgemeinsten Typ ab. Ordnen Sie die catch-Blöcke so an, dass Sie zuerst gezielt behandelbare Ausnahmen abfangen, etwa Datei-, PDF-Passwort- und Codierungsfehler. Fangen Sie den Basistyp zuletzt ab. Der Namespace IronBarCode.Exceptions definiert 11 Ausnahmetypen für unterschiedliche Fehlerfälle:
| Ausnahmetyp | Auslöser | Empfohlene Lösung |
|---|---|---|
IronBarCodeFileException | Die Datei ist beschädigt, gesperrt oder liegt in einem nicht unterstützten Bildformat vor. | Prüfen Sie, ob die Datei ein unterstütztes Bildformat aufweist und nicht gesperrt ist; fangen Sie außerdem FileNotFoundException für fehlende Dateien separat ab. |
IronBarCodePdfPasswordException | Die PDF-Datei ist passwortgeschützt oder verschlüsselt. | Geben Sie das Passwort über PdfBarcodeReaderOptions an oder überspringen Sie die Datei und protokollieren Sie den Fehler. |
IronBarCodeEncodingException | Allgemeiner Codierungsfehler beim Erstellen eines Barcodes. | Prüfen Sie, ob die Eingabedaten die Vorgaben von BarcodeWriterEncoding erfüllen. |
IronBarCodeContentTooLongEncodingException | Der Wert überschreitet die maximale Zeichenanzahl des gewählten Barcode-Formats. | Kürzen Sie die Daten oder wechseln Sie zu einem Format mit höherer Kapazität (QR, DataMatrix). |
IronBarCodeFormatOnlyAcceptsNumericValuesEncodingException | Ein Format, das nur Ziffern erlaubt (EAN, UPC), hat nicht numerische Zeichen erhalten. | Bereinigen Sie die Eingabe oder wechseln Sie zu einem alphanumerischen Format (Code128, Code39). |
IronBarCodeUnsupportedRendererEncodingException | IronBarcode kann keine Barcodes mit der gewählten BarcodeEncoding erzeugen. | Verwenden Sie die Enumeration BarcodeWriterEncoding anstelle von BarcodeEncoding |
IronBarCodeParsingException | Die strukturierten Daten (GS1-128) bestehen beim Parsen die Validierung nicht. | Validieren Sie die GS1-Struktur vor dem Parsen mit Code128GS1Parser.IsValid(). |
IronBarCodeNativeException | Fehler in der nativen Interop-Schicht (fehlende DLLs, Plattforminkompatibilität) | Prüfen Sie, ob die plattformspezifischen NuGet-Pakete installiert sind (BarCode.Linux, BarCode.macOS). |
IronBarCodeConfidenceThresholdException | Ungültiges Argument für den Konfidenzschwellenwert an die Leseroptionen übergeben | Stellen Sie sicher, dass ConfidenceThreshold zwischen 0,0 und 1,0 liegt. |
IronBarCodeUnsupportedException | Dieser Vorgang wird im aktuellen Kontext nicht unterstützt. | Prüfen Sie im Changelog, ob die Funktion in Ihrer Version verfügbar ist. |
IronBarCodeException | Basistyp - fängt jeden IronBarcode-spezifischen Fehler ab, der oben nicht erfasst wurde | Protokollieren Sie sämtliche Details der Ausnahme und leiten Sie den Fall zur weiteren Untersuchung weiter. |
Verwenden Sie Ausnahmefilter mit when-Klauseln, um überlappende Ausnahmetypen ohne tiefe Verschachtelung zu behandeln. Bei fehlenden Dateien wird die Standardausnahme System.IO.FileNotFoundException statt IronBarCodeFileException ausgelöst. Fügen Sie dafür einen eigenen catch-Block hinzu:
Eingabe
Ein Code128-Barcode, der eine Rechnungsnummer kodiert (Erfolgspfad), und ein Lageretiketten-Barcode, der den Inhalt der fehlenden PDF-Datei darstellt (Fehlerpfad).

scanned-invoice.png (Erfolgsfall)

warehouse-labels.pdf (Fehlerfall: Datei fehlt auf dem Datenträger)
using IronBarCode;
using IronBarCode.Exceptions;
// Success path: valid file present on disk
string filePath = "scanned-invoice.png";
// Failure path: file does not exist → caught by FileNotFoundException below
// string filePath = "warehouse-labels.pdf";
try
{
BarcodeResults results = BarcodeReader.Read(filePath);
foreach (BarcodeResult result in results)
{
// Print the detected symbology and decoded value for each barcode found
Console.WriteLine($"[{result.BarcodeType}] {result.Value}");
}
}
catch (IronBarCodePdfPasswordException ex)
{
// PDF is encrypted — supply the password via PdfBarcodeReaderOptions before retrying
Console.Error.WriteLine($"PDF requires password: {filePath} — {ex.Message}");
}
catch (IronBarCodeFileException ex)
{
// File is present but corrupted, locked, or in an unsupported format
Console.Error.WriteLine($"Cannot read file: {filePath} — {ex.Message}");
}
catch (FileNotFoundException ex)
{
// Missing files throw FileNotFoundException, not IronBarCodeFileException
Console.Error.WriteLine($"File not found: {filePath} — {ex.Message}");
}
catch (IronBarCodeNativeException ex) when (ex.Message.Contains("DLL"))
{
// The when filter routes only missing-DLL errors here; other native exceptions
// fall through to the IronBarCodeException block below
Console.Error.WriteLine($"Missing native dependency: {ex.Message}");
}
catch (IronBarCodeException ex)
{
// Base catch for any IronBarcode-specific error not matched by the blocks above
Console.Error.WriteLine($"IronBarcode error: {ex.GetType().Name} — {ex.Message}");
}using IronBarCode;
using IronBarCode.Exceptions;
// Success path: valid file present on disk
string filePath = "scanned-invoice.png";
// Failure path: file does not exist → caught by FileNotFoundException below
// string filePath = "warehouse-labels.pdf";
try
{
BarcodeResults results = BarcodeReader.Read(filePath);
foreach (BarcodeResult result in results)
{
// Print the detected symbology and decoded value for each barcode found
Console.WriteLine($"[{result.BarcodeType}] {result.Value}");
}
}
catch (IronBarCodePdfPasswordException ex)
{
// PDF is encrypted — supply the password via PdfBarcodeReaderOptions before retrying
Console.Error.WriteLine($"PDF requires password: {filePath} — {ex.Message}");
}
catch (IronBarCodeFileException ex)
{
// File is present but corrupted, locked, or in an unsupported format
Console.Error.WriteLine($"Cannot read file: {filePath} — {ex.Message}");
}
catch (FileNotFoundException ex)
{
// Missing files throw FileNotFoundException, not IronBarCodeFileException
Console.Error.WriteLine($"File not found: {filePath} — {ex.Message}");
}
catch (IronBarCodeNativeException ex) when (ex.Message.Contains("DLL"))
{
// The when filter routes only missing-DLL errors here; other native exceptions
// fall through to the IronBarCodeException block below
Console.Error.WriteLine($"Missing native dependency: {ex.Message}");
}
catch (IronBarCodeException ex)
{
// Base catch for any IronBarcode-specific error not matched by the blocks above
Console.Error.WriteLine($"IronBarcode error: {ex.GetType().Name} — {ex.Message}");
}Imports IronBarCode
Imports IronBarCode.Exceptions
' Success path: valid file present on disk
Dim filePath As String = "scanned-invoice.png"
' Failure path: file does not exist → caught by FileNotFoundException below
' Dim filePath As String = "warehouse-labels.pdf"
Try
Dim results As BarcodeResults = BarcodeReader.Read(filePath)
For Each result As BarcodeResult In results
' Print the detected symbology and decoded value for each barcode found
Console.WriteLine($"[{result.BarcodeType}] {result.Value}")
Next
Catch ex As IronBarCodePdfPasswordException
' PDF is encrypted — supply the password via PdfBarcodeReaderOptions before retrying
Console.Error.WriteLine($"PDF requires password: {filePath} — {ex.Message}")
Catch ex As IronBarCodeFileException
' File is present but corrupted, locked, or in an unsupported format
Console.Error.WriteLine($"Cannot read file: {filePath} — {ex.Message}")
Catch ex As FileNotFoundException
' Missing files throw FileNotFoundException, not IronBarCodeFileException
Console.Error.WriteLine($"File not found: {filePath} — {ex.Message}")
Catch ex As IronBarCodeNativeException When ex.Message.Contains("DLL")
' The when filter routes only missing-DLL errors here; other native exceptions
' fall through to the IronBarCodeException block below
Console.Error.WriteLine($"Missing native dependency: {ex.Message}")
Catch ex As IronBarCodeException
' Base catch for any IronBarcode-specific error not matched by the blocks above
Console.Error.WriteLine($"IronBarcode error: {ex.GetType().Name} — {ex.Message}")
End TryImports IronBarCode
Imports IronBarCode.Exceptions
' Success path: valid file present on disk
Dim filePath As String = "scanned-invoice.png"
' Failure path: file does not exist → caught by FileNotFoundException below
' Dim filePath As String = "warehouse-labels.pdf"
Try
Dim results As BarcodeResults = BarcodeReader.Read(filePath)
For Each result As BarcodeResult In results
' Print the detected symbology and decoded value for each barcode found
Console.WriteLine($"[{result.BarcodeType}] {result.Value}")
Next
Catch ex As IronBarCodePdfPasswordException
' PDF is encrypted — supply the password via PdfBarcodeReaderOptions before retrying
Console.Error.WriteLine($"PDF requires password: {filePath} — {ex.Message}")
Catch ex As IronBarCodeFileException
' File is present but corrupted, locked, or in an unsupported format
Console.Error.WriteLine($"Cannot read file: {filePath} — {ex.Message}")
Catch ex As FileNotFoundException
' Missing files throw FileNotFoundException, not IronBarCodeFileException
Console.Error.WriteLine($"File not found: {filePath} — {ex.Message}")
Catch ex As IronBarCodeNativeException When ex.Message.Contains("DLL")
' The when filter routes only missing-DLL errors here; other native exceptions
' fall through to the IronBarCodeException block below
Console.Error.WriteLine($"Missing native dependency: {ex.Message}")
Catch ex As IronBarCodeException
' Base catch for any IronBarcode-specific error not matched by the blocks above
Console.Error.WriteLine($"IronBarcode error: {ex.GetType().Name} — {ex.Message}")
End TryAusgabe
![Konsolenausgabe mit erfolgreicher Code128-Dekodierung: [Code128] INV-2024-7829](/static-assets/barcode/how-to/detailed-error-messages/output-exception-hierarchy-success.webp)
Eine fehlende Datei löst FileNotFoundException aus. Der zugehörige catch-Block fängt die Ausnahme ab.

Der when (ex.Message.Contains("DLL"))-Filter auf IronBarCodeNativeException leitet Fehler aufgrund fehlender Abhängigkeiten zu einem speziellen Handler, ohne andere native Ausnahmen zu beeinträchtigen. Dieser Ansatz ist besonders nützlich bei Docker-Bereitstellungen, bei denen plattformspezifische Pakete fehlen könnten.
IronSoftware.Exceptions.LicensingException wird separat ausgelöst, wenn der Lizenzschlüssel ungültig ist oder fehlt. Fangen Sie diese Ausnahme beim Anwendungsstart ab, nicht bei einzelnen Lese- oder Schreibaufrufen.
Wie extrahiere ich Diagnosedetails aus fehlgeschlagenen Lesevorgängen?
Ein Lesevorgang ohne Treffer liefert eine leere BarcodeResults-Sammlung und löst keine Ausnahme aus. Prüfen Sie zur Diagnose die Eingabeparameter, die eingestellten Optionen und etwaige Teilergebnisse.
Für die nachträgliche Fehleranalyse stellt BarcodeResult unter anderem die Eigenschaften BarcodeType, Value, PageNumber und Points (Eckkoordinaten) bereit. Liegen unerwartete Ergebnisse vor, vergleichen Sie zunächst BarcodeType mit dem erwarteten Format und prüfen Sie PageNumber.
Eingabe
Das Beispiel liest einen Code128-Barcode mit einer Rechnungsnummer. ExpectBarcodeTypes ist auf Code128 und QRCode eingestellt. ReadingSpeed.Detailed sorgt für eine gründliche Suche.

using IronBarCode;
string filePath = "scanned-invoice.png";
// Configure the reader to narrow the search to specific symbologies and use
// a thorough scan pass — narrows false positives and improves decode accuracy
var options = new BarcodeReaderOptions
{
ExpectBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode, // limit scan to known formats
Speed = ReadingSpeed.Detailed, // slower but more thorough — use ExtremeDetail for damaged images
ExpectMultipleBarcodes = true // scan the full image rather than stopping at the first match
};
BarcodeResults results = BarcodeReader.Read(filePath, options);
// An empty result is not an exception — it means no barcode matched the configured options
if (results == null || results.Count == 0)
{
// Log the configured options alongside the warning so the cause is immediately actionable
Console.Error.WriteLine($"[WARN] No barcodes found in: {filePath}");
Console.Error.WriteLine($" ExpectedTypes: {options.ExpectBarcodeTypes}");
Console.Error.WriteLine($" Speed: {options.Speed}");
Console.Error.WriteLine($" Action: Retry with ReadingSpeed.ExtremeDetail or broaden ExpectBarcodeTypes");
}
else
{
foreach (BarcodeResult result in results)
{
// Points contains the four corner coordinates of the barcode in the image;
// use the first corner as a representative position indicator
string pos = result.Points.Length > 0 ? $"{result.Points[0].X:F0},{result.Points[0].Y:F0}" : "N/A";
Console.WriteLine($"[{result.BarcodeType}] {result.Value} "
+ $"(Page: {result.PageNumber}, Position: {pos})");
}
}using IronBarCode;
string filePath = "scanned-invoice.png";
// Configure the reader to narrow the search to specific symbologies and use
// a thorough scan pass — narrows false positives and improves decode accuracy
var options = new BarcodeReaderOptions
{
ExpectBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode, // limit scan to known formats
Speed = ReadingSpeed.Detailed, // slower but more thorough — use ExtremeDetail for damaged images
ExpectMultipleBarcodes = true // scan the full image rather than stopping at the first match
};
BarcodeResults results = BarcodeReader.Read(filePath, options);
// An empty result is not an exception — it means no barcode matched the configured options
if (results == null || results.Count == 0)
{
// Log the configured options alongside the warning so the cause is immediately actionable
Console.Error.WriteLine($"[WARN] No barcodes found in: {filePath}");
Console.Error.WriteLine($" ExpectedTypes: {options.ExpectBarcodeTypes}");
Console.Error.WriteLine($" Speed: {options.Speed}");
Console.Error.WriteLine($" Action: Retry with ReadingSpeed.ExtremeDetail or broaden ExpectBarcodeTypes");
}
else
{
foreach (BarcodeResult result in results)
{
// Points contains the four corner coordinates of the barcode in the image;
// use the first corner as a representative position indicator
string pos = result.Points.Length > 0 ? $"{result.Points[0].X:F0},{result.Points[0].Y:F0}" : "N/A";
Console.WriteLine($"[{result.BarcodeType}] {result.Value} "
+ $"(Page: {result.PageNumber}, Position: {pos})");
}
}Imports IronBarCode
Dim filePath As String = "scanned-invoice.png"
' Configure the reader to narrow the search to specific symbologies and use
' a thorough scan pass — narrows false positives and improves decode accuracy
Dim options As New BarcodeReaderOptions With {
.ExpectBarcodeTypes = BarcodeEncoding.Code128 Or BarcodeEncoding.QRCode, ' limit scan to known formats
.Speed = ReadingSpeed.Detailed, ' slower but more thorough — use ExtremeDetail for damaged images
.ExpectMultipleBarcodes = True ' scan the full image rather than stopping at the first match
}
Dim results As BarcodeResults = BarcodeReader.Read(filePath, options)
' An empty result is not an exception — it means no barcode matched the configured options
If results Is Nothing OrElse results.Count = 0 Then
' Log the configured options alongside the warning so the cause is immediately actionable
Console.Error.WriteLine($"[WARN] No barcodes found in: {filePath}")
Console.Error.WriteLine($" ExpectedTypes: {options.ExpectBarcodeTypes}")
Console.Error.WriteLine($" Speed: {options.Speed}")
Console.Error.WriteLine($" Action: Retry with ReadingSpeed.ExtremeDetail or broaden ExpectBarcodeTypes")
Else
For Each result As BarcodeResult In results
' Points contains the four corner coordinates of the barcode in the image;
' use the first corner as a representative position indicator
Dim pos As String = If(result.Points.Length > 0, $"{result.Points(0).X:F0},{result.Points(0).Y:F0}", "N/A")
Console.WriteLine($"[{result.BarcodeType}] {result.Value} " &
$"(Page: {result.PageNumber}, Position: {pos})")
Next
End IfImports IronBarCode
Dim filePath As String = "scanned-invoice.png"
' Configure the reader to narrow the search to specific symbologies and use
' a thorough scan pass — narrows false positives and improves decode accuracy
Dim options As New BarcodeReaderOptions With {
.ExpectBarcodeTypes = BarcodeEncoding.Code128 Or BarcodeEncoding.QRCode, ' limit scan to known formats
.Speed = ReadingSpeed.Detailed, ' slower but more thorough — use ExtremeDetail for damaged images
.ExpectMultipleBarcodes = True ' scan the full image rather than stopping at the first match
}
Dim results As BarcodeResults = BarcodeReader.Read(filePath, options)
' An empty result is not an exception — it means no barcode matched the configured options
If results Is Nothing OrElse results.Count = 0 Then
' Log the configured options alongside the warning so the cause is immediately actionable
Console.Error.WriteLine($"[WARN] No barcodes found in: {filePath}")
Console.Error.WriteLine($" ExpectedTypes: {options.ExpectBarcodeTypes}")
Console.Error.WriteLine($" Speed: {options.Speed}")
Console.Error.WriteLine($" Action: Retry with ReadingSpeed.ExtremeDetail or broaden ExpectBarcodeTypes")
Else
For Each result As BarcodeResult In results
' Points contains the four corner coordinates of the barcode in the image;
' use the first corner as a representative position indicator
Dim pos As String = If(result.Points.Length > 0, $"{result.Points(0).X:F0},{result.Points(0).Y:F0}", "N/A")
Console.WriteLine($"[{result.BarcodeType}] {result.Value} " &
$"(Page: {result.PageNumber}, Position: {pos})")
Next
End IfAusgabe
ExpectBarcodeTypes mit dem Barcode im Bild übereinstimmt, gibt das Lesen Typ, Wert, Seitennummer und Position zurück.
Wenn ExpectBarcodeTypes das tatsächliche Barcode-Format nicht enthält, bleibt das Ergebnis leer. Der [WARN]-Block protokolliert die eingestellten Formate, die Lesegeschwindigkeit und einen Vorschlag für den nächsten Schritt.
![Konsolenausgabe mit [WARN]-Meldung: Kein Barcode gefunden, weil ExpectBarcodeTypes auf Code39 eingestellt ist, das Bild jedoch einen Code128-Barcode enthält](/static-assets/barcode/how-to/detailed-error-messages/output-diagnostic-logging-failure.webp)
Bei der Diagnose zeigen sich häufig zwei Muster. Bleibt das Ergebnis bei einer eng gefassten Einstellung für ExpectBarcodeTypes leer, verwendet der Barcode oft ein anderes Format. Prüfen Sie dies mit BarcodeEncoding.All. Unerwartete decodierte Werte deuten meist auf eine schlechte Bildqualität hin.
Wenden Sie Bildfilter an und wiederholen Sie den Lesevorgang mit einer niedrigeren Lesegeschwindigkeit. Das behebt diese Probleme oft. Mit der Option RemoveFalsePositive können Sie außerdem verhindern, dass Bildrauschen im Hintergrund zu falsch positiven Erkennungen führt.
Wie aktiviere ich die ausführliche Protokollierung für Barcode-Operationen?
IronBarcode stellt über IronSoftware.Logger eine integrierte Protokollierungs-API bereit. Legen Sie den Protokollierungsmodus und den Dateipfad fest, bevor Sie Barcodes lesen oder schreiben, damit die internen Diagnoseausgaben beider Vorgänge erfasst werden.
Eingabe
Bei aktivierter ausführlicher Protokollierung dient ein TIFF-Bild mit einem Code128-Barcode als Eingabe für den Lesevorgang.

using IronBarCode;
// Enable IronBarcode's built-in logging — set BEFORE any read/write calls
// LoggingModes.All writes both debug output and file-level diagnostics
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = "ironbarcode-debug.log"; // path is relative to the working directory
// All subsequent operations will write internal processing steps to the log file:
// image pre-processing stages, format detection attempts, and native interop calls
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Detailed,
ExpectBarcodeTypes = BarcodeEncoding.All // scan for every supported symbology
};
BarcodeResults results = BarcodeReader.Read("problem-scan.tiff", options);
Console.WriteLine($"Read complete. Results: {results.Count}. See ironbarcode-debug.log for details.");using IronBarCode;
// Enable IronBarcode's built-in logging — set BEFORE any read/write calls
// LoggingModes.All writes both debug output and file-level diagnostics
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = "ironbarcode-debug.log"; // path is relative to the working directory
// All subsequent operations will write internal processing steps to the log file:
// image pre-processing stages, format detection attempts, and native interop calls
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Detailed,
ExpectBarcodeTypes = BarcodeEncoding.All // scan for every supported symbology
};
BarcodeResults results = BarcodeReader.Read("problem-scan.tiff", options);
Console.WriteLine($"Read complete. Results: {results.Count}. See ironbarcode-debug.log for details.");Imports IronBarCode
' Enable IronBarcode's built-in logging — set BEFORE any read/write calls
' LoggingModes.All writes both debug output and file-level diagnostics
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All
IronSoftware.Logger.LogFilePath = "ironbarcode-debug.log" ' path is relative to the working directory
' All subsequent operations will write internal processing steps to the log file:
' image pre-processing stages, format detection attempts, and native interop calls
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Detailed,
.ExpectBarcodeTypes = BarcodeEncoding.All ' scan for every supported symbology
}
Dim results As BarcodeResults = BarcodeReader.Read("problem-scan.tiff", options)
Console.WriteLine($"Read complete. Results: {results.Count}. See ironbarcode-debug.log for details.")Imports IronBarCode
' Enable IronBarcode's built-in logging — set BEFORE any read/write calls
' LoggingModes.All writes both debug output and file-level diagnostics
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All
IronSoftware.Logger.LogFilePath = "ironbarcode-debug.log" ' path is relative to the working directory
' All subsequent operations will write internal processing steps to the log file:
' image pre-processing stages, format detection attempts, and native interop calls
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Detailed,
.ExpectBarcodeTypes = BarcodeEncoding.All ' scan for every supported symbology
}
Dim results As BarcodeResults = BarcodeReader.Read("problem-scan.tiff", options)
Console.WriteLine($"Read complete. Results: {results.Count}. See ironbarcode-debug.log for details.")LoggingModes.All erfasst sowohl die Debug-Ausgabe als auch die Protokollierung in eine Datei. Die Protokolldatei zeichnet interne Verarbeitungsschritte auf, die über die öffentliche API nicht sichtbar sind, etwa die Bildvorverarbeitung, Versuche zur Formaterkennung und native Interop-Aufrufe.
Wenn Ihre Produktionspipeline ein Framework zur strukturierten Protokollierung verwendet (Serilog, NLog, Microsoft.Extensions.Logging), können Sie IronBarcode-Aufrufe in eine Middleware einbetten, die zusätzlich zur integrierten Protokolldatei strukturierte JSON-Einträge erzeugt. Die integrierte Protokollierung schreibt Diagnoseinformationen im Klartext für Fälle, die Sie an den Support weiterleiten. Die Middleware stellt abfragbare Felder für Ihre Observability-Werkzeuge bereit.
using IronBarCode;
using System.Diagnostics;
// Lightweight wrapper that adds structured JSON observability to every read call.
// Call this in place of BarcodeReader.Read wherever elapsed-time and status logging is needed.
BarcodeResults ReadWithDiagnostics(string filePath, BarcodeReaderOptions options)
{
var sw = Stopwatch.StartNew(); // start timing before the read so setup overhead is included
try
{
BarcodeResults results = BarcodeReader.Read(filePath, options);
sw.Stop();
// Emit a structured success entry to stdout — pipe to Fluentd, Datadog, or CloudWatch
Console.WriteLine($"{{\"file\":\"{filePath}\",\"status\":\"ok\","
+ $"\"count\":{results.Count},\"elapsed_ms\":{sw.ElapsedMilliseconds}}}");
return results;
}
catch (Exception ex)
{
sw.Stop();
// Emit a structured error entry to stderr with exception type, message, and elapsed time
Console.Error.WriteLine($"{{\"file\":\"{filePath}\",\"status\":\"error\","
+ $"\"exception\":\"{ex.GetType().Name}\",\"message\":\"{ex.Message}\","
+ $"\"elapsed_ms\":{sw.ElapsedMilliseconds}}}");
throw; // rethrow so the caller's catch blocks still handle the exception normally
}
}using IronBarCode;
using System.Diagnostics;
// Lightweight wrapper that adds structured JSON observability to every read call.
// Call this in place of BarcodeReader.Read wherever elapsed-time and status logging is needed.
BarcodeResults ReadWithDiagnostics(string filePath, BarcodeReaderOptions options)
{
var sw = Stopwatch.StartNew(); // start timing before the read so setup overhead is included
try
{
BarcodeResults results = BarcodeReader.Read(filePath, options);
sw.Stop();
// Emit a structured success entry to stdout — pipe to Fluentd, Datadog, or CloudWatch
Console.WriteLine($"{{\"file\":\"{filePath}\",\"status\":\"ok\","
+ $"\"count\":{results.Count},\"elapsed_ms\":{sw.ElapsedMilliseconds}}}");
return results;
}
catch (Exception ex)
{
sw.Stop();
// Emit a structured error entry to stderr with exception type, message, and elapsed time
Console.Error.WriteLine($"{{\"file\":\"{filePath}\",\"status\":\"error\","
+ $"\"exception\":\"{ex.GetType().Name}\",\"message\":\"{ex.Message}\","
+ $"\"elapsed_ms\":{sw.ElapsedMilliseconds}}}");
throw; // rethrow so the caller's catch blocks still handle the exception normally
}
}Imports IronBarCode
Imports System.Diagnostics
' Lightweight wrapper that adds structured JSON observability to every read call.
' Call this in place of BarcodeReader.Read wherever elapsed-time and status logging is needed.
Function ReadWithDiagnostics(filePath As String, options As BarcodeReaderOptions) As BarcodeResults
Dim sw As Stopwatch = Stopwatch.StartNew() ' start timing before the read so setup overhead is included
Try
Dim results As BarcodeResults = BarcodeReader.Read(filePath, options)
sw.Stop()
' Emit a structured success entry to stdout — pipe to Fluentd, Datadog, or CloudWatch
Console.WriteLine($"{{""file"":""{filePath}"",""status"":""ok"",""count"":{results.Count},""elapsed_ms"":{sw.ElapsedMilliseconds}}}")
Return results
Catch ex As Exception
sw.Stop()
' Emit a structured error entry to stderr with exception type, message, and elapsed time
Console.Error.WriteLine($"{{""file"":""{filePath}"",""status"":""error"",""exception"":""{ex.GetType().Name}"",""message"":""{ex.Message}"",""elapsed_ms"":{sw.ElapsedMilliseconds}}}")
Throw ' rethrow so the caller's catch blocks still handle the exception normally
End Try
End FunctionImports IronBarCode
Imports System.Diagnostics
' Lightweight wrapper that adds structured JSON observability to every read call.
' Call this in place of BarcodeReader.Read wherever elapsed-time and status logging is needed.
Function ReadWithDiagnostics(filePath As String, options As BarcodeReaderOptions) As BarcodeResults
Dim sw As Stopwatch = Stopwatch.StartNew() ' start timing before the read so setup overhead is included
Try
Dim results As BarcodeResults = BarcodeReader.Read(filePath, options)
sw.Stop()
' Emit a structured success entry to stdout — pipe to Fluentd, Datadog, or CloudWatch
Console.WriteLine($"{{""file"":""{filePath}"",""status"":""ok"",""count"":{results.Count},""elapsed_ms"":{sw.ElapsedMilliseconds}}}")
Return results
Catch ex As Exception
sw.Stop()
' Emit a structured error entry to stderr with exception type, message, and elapsed time
Console.Error.WriteLine($"{{""file"":""{filePath}"",""status"":""error"",""exception"":""{ex.GetType().Name}"",""message"":""{ex.Message}"",""elapsed_ms"":{sw.ElapsedMilliseconds}}}")
Throw ' rethrow so the caller's catch blocks still handle the exception normally
End Try
End FunctionDie strukturierte Ausgabe lässt sich direkt mit Werkzeugen zur Protokollaggregation nutzen. Leiten Sie bei der Bereitstellung in Containern stdout an Fluentd, Datadog oder CloudWatch weiter. Das Feld für die verstrichene Zeit macht Leistungseinbußen sichtbar, bevor sie zu SLA-Verletzungen führen.
Ausgabe

Wie kann ich die Stapelverarbeitung von Barcodes debuggen?
Verarbeiten Sie mehrere Dateien, indem Sie jeden Lesevorgang in einem eigenen try-catch-Block ausführen. Halten Sie das Ergebnis pro Datei fest und erstellen Sie anschließend eine Gesamtübersicht. Die Pipeline kann so nach einem Fehler mit der nächsten Datei fortfahren.
Eingabe
Vier der fünf Code128-Barcode-Bilder aus dem scans/-Batch-Verzeichnis. Die fünfte Datei (scan-05-broken.png) enthält ungültige Bytes, um eine Dateiausnahme auszulösen.

Stapel 1 – Scan 1

Stapel 1 – Scan 2

Stapel 1 – Scan 3

Stapel 1 – Scan 4
using IronBarCode;
using IronBarCode.Exceptions;
using System.Diagnostics;
// Enable built-in logging for the entire batch run so internal processing steps
// are captured in the log file alongside the per-file console output
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = "batch-run.log";
// Collect all files in the directory — SearchOption.TopDirectoryOnly skips subdirectories
string[] files = Directory.GetFiles("scans/", "*.*", SearchOption.TopDirectoryOnly);
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced, // balances throughput vs accuracy
ExpectBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode, // limit to known formats
ExpectMultipleBarcodes = true // scan each file fully
};
// Three outcome counters: success (decoded), empty (read OK but no barcode found), fail (exception)
int successCount = 0;
int failCount = 0;
int emptyCount = 0;
var errors = new List<(string File, string Error)>(); // per-file error context for root cause analysis
var sw = Stopwatch.StartNew();
foreach (string file in files)
{
try
{
BarcodeResults results = BarcodeReader.Read(file, options);
// Empty result is not an exception — the file was read but contained no matching barcode
if (results == null || results.Count == 0)
{
emptyCount++;
errors.Add((file, "No barcodes detected")); // record so caller can adjust options
continue;
}
foreach (BarcodeResult result in results)
{
Console.WriteLine($"{Path.GetFileName(file)} | {result.BarcodeType} | {result.Value}");
}
successCount++;
}
catch (IronBarCodePdfPasswordException)
{
// PDF is password-protected — supply password via PdfBarcodeReaderOptions to recover
failCount++;
errors.Add((file, "Password-protected PDF"));
}
catch (IronBarCodeFileException ex)
{
// File is corrupted, locked, or in an unsupported image format
failCount++;
errors.Add((file, $"File error: {ex.Message}"));
}
catch (FileNotFoundException ex)
{
// File was in the directory listing but deleted before the read completed (race condition)
failCount++;
errors.Add((file, $"File not found: {ex.Message}"));
}
catch (IronBarCodeException ex)
{
// Catch-all for any other IronBarcode-specific errors not handled above
failCount++;
errors.Add((file, $"{ex.GetType().Name}: {ex.Message}"));
}
catch (Exception ex)
{
// Unexpected non-IronBarcode error — log the full type for investigation
failCount++;
errors.Add((file, $"Unexpected: {ex.GetType().Name}: {ex.Message}"));
}
}
sw.Stop();
// Summary report — parse failCount > 0 in CI/CD to set a non-zero exit code
Console.WriteLine("\n--- Batch Summary ---");
Console.WriteLine($"Total files: {files.Length}");
Console.WriteLine($"Success: {successCount}");
Console.WriteLine($"Empty reads: {emptyCount}");
Console.WriteLine($"Failures: {failCount}");
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalSeconds:F1}s");
if (errors.Any())
{
Console.WriteLine("\n--- Error Details ---");
foreach (var (errorFile, errorMsg) in errors)
{
Console.Error.WriteLine($" {Path.GetFileName(errorFile)}: {errorMsg}");
}
}using IronBarCode;
using IronBarCode.Exceptions;
using System.Diagnostics;
// Enable built-in logging for the entire batch run so internal processing steps
// are captured in the log file alongside the per-file console output
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All;
IronSoftware.Logger.LogFilePath = "batch-run.log";
// Collect all files in the directory — SearchOption.TopDirectoryOnly skips subdirectories
string[] files = Directory.GetFiles("scans/", "*.*", SearchOption.TopDirectoryOnly);
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced, // balances throughput vs accuracy
ExpectBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode, // limit to known formats
ExpectMultipleBarcodes = true // scan each file fully
};
// Three outcome counters: success (decoded), empty (read OK but no barcode found), fail (exception)
int successCount = 0;
int failCount = 0;
int emptyCount = 0;
var errors = new List<(string File, string Error)>(); // per-file error context for root cause analysis
var sw = Stopwatch.StartNew();
foreach (string file in files)
{
try
{
BarcodeResults results = BarcodeReader.Read(file, options);
// Empty result is not an exception — the file was read but contained no matching barcode
if (results == null || results.Count == 0)
{
emptyCount++;
errors.Add((file, "No barcodes detected")); // record so caller can adjust options
continue;
}
foreach (BarcodeResult result in results)
{
Console.WriteLine($"{Path.GetFileName(file)} | {result.BarcodeType} | {result.Value}");
}
successCount++;
}
catch (IronBarCodePdfPasswordException)
{
// PDF is password-protected — supply password via PdfBarcodeReaderOptions to recover
failCount++;
errors.Add((file, "Password-protected PDF"));
}
catch (IronBarCodeFileException ex)
{
// File is corrupted, locked, or in an unsupported image format
failCount++;
errors.Add((file, $"File error: {ex.Message}"));
}
catch (FileNotFoundException ex)
{
// File was in the directory listing but deleted before the read completed (race condition)
failCount++;
errors.Add((file, $"File not found: {ex.Message}"));
}
catch (IronBarCodeException ex)
{
// Catch-all for any other IronBarcode-specific errors not handled above
failCount++;
errors.Add((file, $"{ex.GetType().Name}: {ex.Message}"));
}
catch (Exception ex)
{
// Unexpected non-IronBarcode error — log the full type for investigation
failCount++;
errors.Add((file, $"Unexpected: {ex.GetType().Name}: {ex.Message}"));
}
}
sw.Stop();
// Summary report — parse failCount > 0 in CI/CD to set a non-zero exit code
Console.WriteLine("\n--- Batch Summary ---");
Console.WriteLine($"Total files: {files.Length}");
Console.WriteLine($"Success: {successCount}");
Console.WriteLine($"Empty reads: {emptyCount}");
Console.WriteLine($"Failures: {failCount}");
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalSeconds:F1}s");
if (errors.Any())
{
Console.WriteLine("\n--- Error Details ---");
foreach (var (errorFile, errorMsg) in errors)
{
Console.Error.WriteLine($" {Path.GetFileName(errorFile)}: {errorMsg}");
}
}Imports IronBarCode
Imports IronBarCode.Exceptions
Imports System.Diagnostics
' Enable built-in logging for the entire batch run so internal processing steps
' are captured in the log file alongside the per-file console output
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All
IronSoftware.Logger.LogFilePath = "batch-run.log"
' Collect all files in the directory — SearchOption.TopDirectoryOnly skips subdirectories
Dim files As String() = Directory.GetFiles("scans/", "*.*", SearchOption.TopDirectoryOnly)
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced, ' balances throughput vs accuracy
.ExpectBarcodeTypes = BarcodeEncoding.Code128 Or BarcodeEncoding.QRCode, ' limit to known formats
.ExpectMultipleBarcodes = True ' scan each file fully
}
' Three outcome counters: success (decoded), empty (read OK but no barcode found), fail (exception)
Dim successCount As Integer = 0
Dim failCount As Integer = 0
Dim emptyCount As Integer = 0
Dim errors As New List(Of (File As String, Error As String))() ' per-file error context for root cause analysis
Dim sw As Stopwatch = Stopwatch.StartNew()
For Each file As String In files
Try
Dim results As BarcodeResults = BarcodeReader.Read(file, options)
' Empty result is not an exception — the file was read but contained no matching barcode
If results Is Nothing OrElse results.Count = 0 Then
emptyCount += 1
errors.Add((file, "No barcodes detected")) ' record so caller can adjust options
Continue For
End If
For Each result As BarcodeResult In results
Console.WriteLine($"{Path.GetFileName(file)} | {result.BarcodeType} | {result.Value}")
Next
successCount += 1
Catch ex As IronBarCodePdfPasswordException
' PDF is password-protected — supply password via PdfBarcodeReaderOptions to recover
failCount += 1
errors.Add((file, "Password-protected PDF"))
Catch ex As IronBarCodeFileException
' File is corrupted, locked, or in an unsupported image format
failCount += 1
errors.Add((file, $"File error: {ex.Message}"))
Catch ex As FileNotFoundException
' File was in the directory listing but deleted before the read completed (race condition)
failCount += 1
errors.Add((file, $"File not found: {ex.Message}"))
Catch ex As IronBarCodeException
' Catch-all for any other IronBarcode-specific errors not handled above
failCount += 1
errors.Add((file, $"{ex.GetType().Name}: {ex.Message}"))
Catch ex As Exception
' Unexpected non-IronBarcode error — log the full type for investigation
failCount += 1
errors.Add((file, $"Unexpected: {ex.GetType().Name}: {ex.Message}"))
End Try
Next
sw.Stop()
' Summary report — parse failCount > 0 in CI/CD to set a non-zero exit code
Console.WriteLine(vbCrLf & "--- Batch Summary ---")
Console.WriteLine($"Total files: {files.Length}")
Console.WriteLine($"Success: {successCount}")
Console.WriteLine($"Empty reads: {emptyCount}")
Console.WriteLine($"Failures: {failCount}")
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalSeconds:F1}s")
If errors.Any() Then
Console.WriteLine(vbCrLf & "--- Error Details ---")
For Each errorDetail In errors
Console.Error.WriteLine($" {Path.GetFileName(errorDetail.File)}: {errorDetail.Error}")
Next
End IfImports IronBarCode
Imports IronBarCode.Exceptions
Imports System.Diagnostics
' Enable built-in logging for the entire batch run so internal processing steps
' are captured in the log file alongside the per-file console output
IronSoftware.Logger.LoggingMode = IronSoftware.Logger.LoggingModes.All
IronSoftware.Logger.LogFilePath = "batch-run.log"
' Collect all files in the directory — SearchOption.TopDirectoryOnly skips subdirectories
Dim files As String() = Directory.GetFiles("scans/", "*.*", SearchOption.TopDirectoryOnly)
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced, ' balances throughput vs accuracy
.ExpectBarcodeTypes = BarcodeEncoding.Code128 Or BarcodeEncoding.QRCode, ' limit to known formats
.ExpectMultipleBarcodes = True ' scan each file fully
}
' Three outcome counters: success (decoded), empty (read OK but no barcode found), fail (exception)
Dim successCount As Integer = 0
Dim failCount As Integer = 0
Dim emptyCount As Integer = 0
Dim errors As New List(Of (File As String, Error As String))() ' per-file error context for root cause analysis
Dim sw As Stopwatch = Stopwatch.StartNew()
For Each file As String In files
Try
Dim results As BarcodeResults = BarcodeReader.Read(file, options)
' Empty result is not an exception — the file was read but contained no matching barcode
If results Is Nothing OrElse results.Count = 0 Then
emptyCount += 1
errors.Add((file, "No barcodes detected")) ' record so caller can adjust options
Continue For
End If
For Each result As BarcodeResult In results
Console.WriteLine($"{Path.GetFileName(file)} | {result.BarcodeType} | {result.Value}")
Next
successCount += 1
Catch ex As IronBarCodePdfPasswordException
' PDF is password-protected — supply password via PdfBarcodeReaderOptions to recover
failCount += 1
errors.Add((file, "Password-protected PDF"))
Catch ex As IronBarCodeFileException
' File is corrupted, locked, or in an unsupported image format
failCount += 1
errors.Add((file, $"File error: {ex.Message}"))
Catch ex As FileNotFoundException
' File was in the directory listing but deleted before the read completed (race condition)
failCount += 1
errors.Add((file, $"File not found: {ex.Message}"))
Catch ex As IronBarCodeException
' Catch-all for any other IronBarcode-specific errors not handled above
failCount += 1
errors.Add((file, $"{ex.GetType().Name}: {ex.Message}"))
Catch ex As Exception
' Unexpected non-IronBarcode error — log the full type for investigation
failCount += 1
errors.Add((file, $"Unexpected: {ex.GetType().Name}: {ex.Message}"))
End Try
Next
sw.Stop()
' Summary report — parse failCount > 0 in CI/CD to set a non-zero exit code
Console.WriteLine(vbCrLf & "--- Batch Summary ---")
Console.WriteLine($"Total files: {files.Length}")
Console.WriteLine($"Success: {successCount}")
Console.WriteLine($"Empty reads: {emptyCount}")
Console.WriteLine($"Failures: {failCount}")
Console.WriteLine($"Elapsed: {sw.Elapsed.TotalSeconds:F1}s")
If errors.Any() Then
Console.WriteLine(vbCrLf & "--- Error Details ---")
For Each errorDetail In errors
Console.Error.WriteLine($" {Path.GetFileName(errorDetail.File)}: {errorDetail.Error}")
Next
End IfAusgabe

Während der Ausführung gibt die Konsole für jeden dekodierten Barcode eine Zeile aus, gefolgt von einer Zusammenfassung mit Dateianzahl, erfolgreichen Lesevorgängen, leeren Lesevorgängen, Fehlern und der verstrichenen Zeit. Fehler werden mit ihren zugehörigen Dateinamen und Fehlergründen aufgelistet.
Der Prozess unterscheidet drei Ergebniskategorien: Erfolg (Barcodes gefunden und dekodiert), leer (Datei gelesen, aber keine Barcodes erkannt) und Fehler (Ausnahme ausgelöst). Diese Unterscheidung ist wichtig, weil leere Lesevorgänge und Fehler unterschiedliche Reaktionen erfordern. Bei leeren Lesevorgängen sind möglicherweise breitere Formateinstellungen erforderlich, während Fehler oft auf Infrastrukturprobleme wie fehlende Dateien, gesperrte Ressourcen oder fehlende native Abhängigkeiten hinweisen.
Die Fehlerliste speichert den Kontext pro Datei für die Ursachenanalyse. Werten Sie diese Ausgabe in einer CI/CD-Pipeline aus, um Exit-Codes festzulegen (0 bei vollständigem Erfolg und ein Wert ungleich 0, wenn failCount größer als 0 ist) oder Fehlerdetails an ein Alarmsystem weiterzuleiten.
Für einen höheren Durchsatz setzen Sie Multithreaded auf true und passen MaxParallelThreads an die Anzahl der verfügbaren CPU-Kerne an. Verarbeiten Sie die Dateien getrennt voneinander mit Parallel.ForEach und verwenden Sie eine threadsichere Sammlung für die Fehlerliste.
Weiterführende Literatur
- IronBarcode-Tutorials: Barcodes lesen: Schritt-für-Schritt-Anleitungen für den gesamten Lesevorgang.
- Falsch positive Erkennungen vermeiden: So verringern Sie fehlerhafte Erkennungen in verrauschten Bildern.
- Anleitung zur Bildkorrektur: Filter, die die Lesepräzision verbessern.
- Docker-Setup-Anleitung: Containerisierte Bereitstellung mit den richtigen nativen Abhängigkeiten.
- API-Referenz für BarcodeReaderOptions: vollständige Konfigurationsdokumentation.
- IronBarcode Changelog: versionsspezifische Fehlerbehebungen und Funktionserweiterungen.
Sobald die Pipeline für den Produktiveinsatz bereit ist, können Sie sich über die Lizenzoptionen informieren.
Häufig gestellte Fragen
Wie kann ich Barcode-Fehler in C# mit IronBarcode behandeln?
Sie können Barcode-Fehler in C# mit IronBarcode behandeln, indem Sie seine typisierte Ausnahmehierarchie innerhalb des IronBarCode.Exceptions-Namespace nutzen. Dies ermöglicht es Ihnen, spezifische Ausnahmen im Zusammenhang mit Datei-Fehlern, PDF-Passwörtern, Codierungsproblemen und mehr abzufangen. Die Implementierung von strukturiertem Logging und die Verwendung der BarcodeResult-Eigenschaften hilft, Probleme effizient zu diagnostizieren und zu isolieren.
Welche häufigen Ausnahmen werden von IronBarcode ausgelöst?
IronBarcode kann verschiedene Ausnahmen auslösen, wie z. B. IronBarCodeFileException für dateibezogene Probleme, IronBarCodePdfPasswordException für kennwortgeschützte PDFs und IronBarCodeEncodingException für Codierungsfehler. Jeder Ausnahmetyp liefert detaillierte Diagnostikinformationen, um spezifische Fehler zu beheben, die während der Barcode-Verarbeitung auftreten.
Wie aktiviere ich Logging für Diagnosen in IronBarcode?
Um Logging für Diagnosen in IronBarcode zu aktivieren, stellen Sie den Logging-Modus und den Dateipfad mit IronSoftware.Logger ein, bevor Sie Barcode-Operationen durchführen. Dies erfasst interne Verarbeitungsschritte und hilft, indem es Protokolle in die angegebene Datei schreibt, Probleme zu verfolgen.
Was soll ich tun, wenn eine Barcode-Leseoperation in IronBarcode null Ergebnisse liefert?
Wenn eine Barcode-Leseoperation in IronBarcode null Ergebnisse liefert, bedeutet dies, dass kein Barcode mit den konfigurierten Optionen übereinstimmt. Überprüfen Sie Ihre Eingabeparameter und -optionen wie ExpectBarcodeTypes und Lesegeschwindigkeit und erwägen Sie, die Erwartungen an die Symbolik zu erweitern oder die Lesegeschwindigkeit für ein gründlicheres Scannen anzupassen.
Kann IronBarcode Ausnahmen für fehlende native Abhängigkeiten behandeln?
Ja, IronBarcode behandelt Ausnahmen für fehlende native Abhängigkeiten durch die IronBarCodeNativeException. Sie können diese Ausnahmen filtern, um fehlende DLLs oder Plattformabhängigkeiten zu identifizieren, was besonders in Docker-Umgebungen nützlich ist.
Wie kann ich die Stapelverarbeitung von Barcodes mit IronBarcode debuggen?
Um die Stapelbarcodeverarbeitung in IronBarcode zu debuggen, isolieren Sie jede Leseoperation in einem eigenen try-catch-Block und erfassen Sie Fehler pro Datei. Dieser Ansatz stellt sicher, dass die Stapeloperation trotz Ausfällen fortgesetzt wird und eine Zusammenfassung der Erfolge, Misserfolge und leeren Ergebnisse generiert wird.
Wie kann ich Ausnahmen effektiv in IronBarcode abfangen und interpretieren?
Fangen und interpretieren Sie Ausnahmen in IronBarcode, indem Sie Ihre try-catch-Blöcke von spezifisch zu allgemein anordnen. Beginnen Sie mit umsetzbaren Ausnahmen wie Datei-Fehlern oder PDF-Passwortproblemen und enden Sie mit der Basis-IronBarCodeException, um eine umfassende Fehlerbehandlung zu gewährleisten.
Welche Eigenschaften von BarcodeResult können für die nachträgliche Analyse verwendet werden?
Das BarcodeResult-Objekt in IronBarcode bietet Eigenschaften wie BarcodeType, Value, PageNumber und Points (Koordinaten) für die nachträgliche Analyse. Diese Eigenschaften helfen, unerwartete Ergebnisse zu verstehen, indem sie den tatsächlichen mit dem erwarteten Barcode-Typ vergleichen und die Seitennummer prüfen.
Wie kann ich in IronBarcode falsch-positive Ergebnisse beim Lesen von Barcodes verhindern?
Um in IronBarcode falsch-positive Ergebnisse beim Lesen von Barcodes zu verhindern, können Sie Bildfilter zur Verbesserung der Bildqualität und die Option RemoveFalsePositive verwenden. Außerdem kann die Anpassung der Lesegeschwindigkeit und ExpectBarcodeTypes Fehler aus lärmigen Hintergründen minimieren.
Wie behandelt IronBarcode Fehler aus verschlüsselten PDFs?
IronBarcode behandelt Fehler aus verschlüsselten PDFs mithilfe der IronBarCodePdfPasswordException. Um solche Dateien zu verarbeiten, geben Sie das Passwort mit PdfBarcodeReaderOptions an oder protokollieren und überspringen Sie sie für eine störungsfreie Barcode-Verarbeitung.
Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender Handbücher.