エラーを処理し、C#でバーコード操作をデバッグする方法
バーコード処理パイプラインは、エラーが発生しても何も通知されない場合があり、結果がゼロと表示されると「バーコードが存在しない」と誤解されることがよくあります。しかし、破損したファイル、パスワードで保護されたPDF、フォーマットの不一致などが原因となっている可能性があります。 適切なログ記録と構造化されたエラー処理を実装することで、これらの障害が明らかになり、実用的な診断情報が得られます。
IronBarcode は、IronBarCode.Exceptions 名前空間内に型付き例外階層、組み込みのロギングAPI、詳細なBarcodeResult プロパティを提供します。 これらのプロパティには、検出されたフォーマット、デコードされた値、ページ番号、およびデコードが成功した各箇所の座標が含まれます。
このハウツーでは、型付き例外をキャッチして解釈する方法、失敗した読み取りからの診断コンテキストを抽出する方法、構造化ロギングを有効にする方法、バッチ操作中の失敗を分離する方法を説明します。
クイックスタート: バーコードエラーの処理と診断の有効化読み取りと書き込みの呼び出しを、IronBarcodeの型付き例外を捕捉するtry-catchブロックで囲み、通知されないままの失敗を防いで対処に役立つエラーメッセージを表示します。
-
1IronBarcode を NuGet Package Manager でインストールします
-
2このコード スニペットをコピーして実行します。
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 -
3実際の環境でテストするためにデプロイする
今日からご自身のプロジェクトでIronBarcodeを使い始めるには、無料トライアルをお試しください。
IronBarcodeでバーコードエラーを処理し、診断機能を有効にする方法
- NuGetからIronBarcodeライブラリをダウンロード
- 特定の例外タイプをターゲットとしたtry-catchブロックで読み書き呼び出しをラップします
- 成功した読み取り後の
BarcodeResultsを検査し、空のエントリや信頼度の低いエントリを確認します IronSoftware.Loggerを有効にして内部の診断出力をキャプチャします- エラー続行ロジックを使用してバッチ操作でファイルごとに個別の失敗を隔離します
IronBarcodeの例外を捕捉して解釈するにはどうすればよいですか?
IronBarcodeの例外を、最も具体的なものから最も一般的なものまで捕捉します。 ファイルエラー、PDFパスワードエラー、エンコードエラーなど、処理が必要な例外を最初に処理するcatchブロックを配置し、その後に基本型を配置します。 IronBarCode.Exceptions名前空間は11の例外タイプを定義し、各タイプは特定の障害モードに対応しています:
| 例外タイプ | トリガー | 推奨される修正 |
|---|---|---|
IronBarCodeFileException | ファイルが破損しているか、ロックされているか、またはサポートされていない画像形式です。 | ファイルがサポートされている画像形式であり、ロックされていないことを検証します。また、ファイルが見つからない場合は、 FileNotFoundExceptionを別途キャッチします。 |
IronBarCodePdfPasswordException | PDFがパスワードで保護されているか暗号化されている | パスワードをPdfBarcodeReaderOptionsを通じて提供するか、ファイルをスキップしてログを記録します |
IronBarCodeEncodingException | バーコード生成中の一般的なエンコーディングエラー | 入力データが目的のBarcodeWriterEncoding制約と一致することを確認します |
IronBarCodeContentTooLongEncodingException | 選択されたシンボロジーで文字数制限を超える | データを切り詰めるか、より高容量のフォーマット(QR, DataMatrix)に切り替えます |
IronBarCodeFormatOnlyAcceptsNumericValuesEncodingException | 数値のみのフォーマット(EAN, UPC)に非数値文字を渡す | 入力をサニタイズするか、英数字フォーマット(Code128, Code39)に切り替えます |
IronBarCodeUnsupportedRendererEncodingException | 選択されたBarcodeEncodingはIronBarcodeで書き出せません | BarcodeEncodingの代わりにBarcodeWriterEncoding列挙型を使用します |
IronBarCodeParsingException | パース中に構造化データ(GS1-128)が検証に失敗する | パース前にCode128GS1Parser.IsValid()を使ってGS1構造を検証します |
IronBarCodeNativeException | ネイティブ相互運用層でのエラー(DLLが見つからない、プラットフォームの互換性) | プラットフォーム固有のNuGetパッケージがインストールされていることを確認します(BarCode.Linux, BarCode.macOS) |
IronBarCodeConfidenceThresholdException | 無効な信頼度しきい値引数がリーダーオプションに渡されている | ConfidenceThresholdが0.0から1.0の間であることを確認します |
IronBarCodeUnsupportedException | 現在のコンテキストではサポートされていない操作 | ご自身のバージョンでの機能の可用性については変更履歴を確認してください |
IronBarCodeException | 基本型 - 上記と一致しないIronBarcode固有のエラーをキャッチします | 完全な例外詳細をログに記録し、調査のためにエスカレーションします |
例外フィルターをwhen句で使用して、深いネストなしで重複する例外タイプをルートします。 ファイルが見つからない場合は標準のSystem.IO.FileNotFoundExceptionがスローされますが、IronBarCodeFileExceptionの場合とは異なるため、このケース用に別のキャッチブロックを含めてください:
入力
請求書番号をエンコードしたCode128バーコード(成功経路)と、欠落したPDFの内容を表す倉庫ラベルバーコード(失敗経路)。

scanned-invoice.png(成功パス)

warehouse-labels.pdf(不在のファイルパス - ディスク上にファイルが存在しません)
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 Try出力
![コンソール出力:Code128デコード成功を示す:[Code128] INV-2024-7829](/static-assets/barcode/how-to/detailed-error-messages/output-exception-hierarchy-success.webp)
不足しているファイルは、専用のキャッチブロックによってFileNotFoundExceptionをトリガーします。

IronBarCodeNativeExceptionのwhen (ex.Message.Contains("DLL"))フィルタは、他のネイティブ例外に影響を与えることなく、依存関係が見つからないエラーを特定のハンドラーに誘導します。 この方法は、プラットフォーム固有のパッケージが不足している可能性があるDocker環境において特に有効です。
ライセンスキーが無効または不足している場合、IronSoftware.Exceptions.LicensingExceptionが個別にスローされます。 この例外は、個々の読み取りまたは書き込み呼び出しの前後ではなく、アプリケーションの起動時に捕捉してください。
読み取り失敗から診断の詳細を抽出するにはどうすればよいですか?
読み取り操作で結果がゼロ件返されることは例外ではありません。 空のBarcodeResultsコレクションを生成します。 診断コンテキストは、入力パラメータ、設定済みオプション、および返された部分的な結果を検査することによって取得されます。
BarcodeResultオブジェクトは、BarcodeType、Value、PageNumber、およびPoints(コーナー座標)など、事後分析に役立つプロパティを提供します。 結果が存在するが予期しない場合、まずBarcodeTypeを期待される形式と比較し、PageNumberを確認してください。
入力
請求書番号をエンコードしたCode128バーコードを読み取ります。ExpectBarcodeTypesにはCode128とQRCodeを指定し、詳細にスキャンするためにReadingSpeed.Detailedを使用します。

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 If出力
ExpectBarcodeTypesが一致すると、読み取りはタイプ、値、ページ番号、位置を返します。
ExpectBarcodeTypesに実際のシンボロジーが含まれていない場合、読み取り結果は空になります。 [WARN] ブロックには、設定されたタイプ、読み取り速度、および推奨される次のアクションがログに記録されます。
![コンソール出力には、[WARN] Code128イメージに対してExpectBarcodeTypesがCode39に設定されているため、バーコードが見つかりませんでしたと表示されます。](/static-assets/barcode/how-to/detailed-error-messages/output-diagnostic-logging-failure.webp)
診断の過程で、2つの共通パターンが現れます。 空の結果で狭いExpectBarcodeTypes設定があると、多くの場合バーコードが異なるシンボロジーを使用していることを意味します; これを確認するためにBarcodeEncoding.Allに拡大できます。 予期しないデコード結果は、通常、画質の悪さを示しています。
画像フィルターを適用し、読み込み速度を遅くして再試行すると、これらの問題は解決することがよくあります。 ノイズの多い背景からのファントムリードを排除するためにRemoveFalsePositiveオプションを切り替えることもできます。
バーコード操作の詳細ログを有効にするにはどうすればよいですか?
IronBarcodeは組み込みのログAPIをIronSoftware.Loggerを介して公開しています。 読み取りおよび書き込みパイプラインからの内部診断出力を取得するには、バーコード操作を行う前にログモードとファイルパスを設定してください。
入力
詳細ログが有効になっている場合、読み取り対象としてCode128バーコードのTIFF画像が使用されます。

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はデバッグ出力とファイルレベルのログを両方キャプチャします。 ログファイルには、画像の前処理段階、フォーマット検出の試行、ネイティブ相互運用呼び出しなど、公開APIからは見えない内部処理手順が記録されます。
構造化ログフレームワーク(Serilog、NLog、Microsoft.Extensions.Logging)を使用する本番パイプラインでは、IronBarcode操作をミドルウェア層でラップして、組み込みのログファイルと並んで構造化JSONエントリを追加します。組み込みのロガーはサポートエスカレーションに役立つプレインテキスト診断を書き込みます; 構造化されたラッパーは、オブザーバビリティスタックに対してクエリ可能なフィールドを提供します。
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 Function構造化された出力は、ログ集約ツールと直接統合されます。 コンテナ化されたデプロイメントでstdoutをFluentd、Datadog、またはCloudWatchにパイプします。 経過時間フィールドは、パフォーマンスの低下がSLA違反となる前にそれを明らかにします。
出力

バッチバーコード処理のデバッグ方法を教えてください
複数のファイルを処理するには、各読み込み処理を個別のtry-catchブロックで分離し、各ファイルの結果を記録し、集計サマリーを生成します。 パイプラインは最初のエラーで停止するのではなく、障害が発生しても処理を継続します。
入力
scans/バッチディレクトリからのCode128バーコード画像のうち4つ。 5番目のファイル(scan-05-broken.png)にはファイル例外をトリガーするための無効なバイトが含まれています。

バッチ1 - スキャン1

バッチ1 - スキャン2

バッチ1 - スキャン3

バッチ1 - スキャン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 If出力

実行中、コンソールにはデコードされたバーコードごとに1行が出力され、その後にファイル数、成功数、空の読み取り数、失敗数、経過時間を含む概要が表示されます。エラーは、対応するファイル名と失敗理由とともに一覧表示されます。
このプロセスでは、成功(バーコードが見つかり、デコードされた)、空(ファイルは読み取られたがバーコードが検出されなかった)、失敗(例外が発生した)の3つの結果カテゴリが区別されます。 この区別は重要です。なぜなら、空の読み取りとエラーには異なる対応が必要となるからです。 空の読み取りが発生する場合は、より広範なフォーマット設定が必要になる可能性があり、エラーが発生する場合は、ファイルの欠落、リソースのロック、ネイティブ依存関係の欠落など、インフラストラクチャの問題を示していることが多くあります。
エラーリストは、根本原因の分析に役立つように、ファイルごとのコンテキストを保持します。CI/CDパイプラインでは、この出力を解析して終了コードを設定する(完全に成功した場合は0、failCountが0を超える場合は0以外)か、エラーの詳細をアラートシステムに転送します。
スループットを向上させるためには、Multithreadedをtrueに設定し、利用可能なCPUコアに合わせてMaxParallelThreadsを調整して、並列処理を有効にしてください。 並列イテレーションをParallel.ForEachでラップし、エラーリストにはスレッドセーフなコレクションを使用して各ファイルの分離性を維持します。
関連資料
- IronBarcodeチュートリアル:バーコードの読み取り:エンドツーエンドの読み取りウォークスルー。
- 誤検知防止:ノイズの多い画像でのファントムリードの削減。
- 画像補正ハウツー:読み取り精度を向上させるフィルター。
- Dockerセットアップガイド:正しいネイティブ依存関係を持つコンテナ化デプロイメント。
- BarcodeReaderOptions APIリファレンス:完全な構成ドキュメント。
- IronBarcode変更履歴:バージョン別の修正と機能追加。
パイプラインの本番稼働準備が整ったら、ライセンスオプションを確認してください。
よくある質問
IronBarcodeを使用してC#でバーコードエラーをどのように処理できますか?
IronBarcodeを使用してC#でバーコードエラーを処理するには、IronBarCode.Exceptions namespace内の型付き例外階層を利用します。これにより、ファイルエラー、PDFパスワード、エンコーディングの問題など、特定の例外をキャッチできます。構造化されたログを実装し、BarcodeResultのプロパティを使用することで、問題の診断と分離を効率的に行えます。
IronBarcodeによってスローされる一般的な例外は何ですか?
IronBarcodeは、ファイル関連の問題に対するIronBarCodeFileException、パスワード保護されたPDFに対するIronBarCodePdfPasswordException、エンコーディングの失敗に対するIronBarCodeEncodingExceptionなど、さまざまな例外をスローする可能性があります。各例外タイプは、バーコード処理中に遭遇する特定のエラーを解決するための詳細な診断情報を提供します。
IronBarcodeで診断用のログを有効にするにはどうすればよいですか?
IronBarcodeで診断用のログを有効にするには、ログモードとファイルパスをIronSoftware.Loggerを使用して、バーコード操作の前に設定します。これにより、内部処理ステップがキャプチャされ、指定されたファイルにログを書き込むことで問題を追跡するのに役立ちます。
IronBarcodeでバーコード読み取り操作がゼロ結果を返した場合、どうすればよいですか?
IronBarcodeでバーコード読み取り操作がゼロ結果を返した場合、構成されたオプションに一致するバーコードがなかったことを示しています。入力パラメータやExpectBarcodeTypes、ReadingSpeedのようなオプションを確認し、シンボロジーの期待値を広げたり、読み取り速度を調整したりして、より徹底的なスキャンを考慮してください。
IronBarcodeは、欠落したネイティブ依存関係に対する例外を処理できますか?
はい、IronBarcodeはIronBarCodeNativeExceptionを通じて、欠落したネイティブ依存関係に対する例外を処理します。これらの例外をフィルタリングして、欠落しているDLLやプラットフォーム依存関係を特定でき、特にDocker環境で役立ちます。
IronBarcodeを使用してバーコードのバッチ処理をデバッグするにはどうすればよいですか?
IronBarcodeでバーコードのバッチ処理をデバッグするには、各読み取り操作を個々のtry-catchブロックに分離し、ファイルごとにエラーをキャプチャします。この方法は、バッチ操作が失敗を通じて続行し、成功、失敗、空の結果を含む要約を生成することを保証します。
IronBarcodeで効果的に例外をキャッチして解釈するにはどうすればよいですか?
IronBarcodeで例外を効果的にキャッチして解釈するには、try-catchブロックを特定から一般的な順に並べます。ファイルエラーやPDFパスワード問題のようなアクション可能な例外から始め、包括的なエラー処理を保証するために基本のIronBarCodeExceptionで終わります。
バーコード結果の分析後に利用できるBarcodeResultのプロパティは何ですか?
IronBarcodeのBarcodeResultオブジェクトは、分析後に利用できるプロパティとして、BarcodeType、Value、PageNumber、ポイント(座標)を提供します。これらのプロパティは、予期せぬ結果を理解し、実際のバーコードタイプと期待されたバーコードタイプを確認し、ページ番号を確認するのに役立ちます。
IronBarcodeでのバーコード読み取り中に誤検出を防ぐにはどうすればよいですか?
IronBarcodeでのバーコード読み取り中に誤検出を防ぐには、画像フィルタを使用して画像品質を向上させ、RemoveFalsePositiveオプションを使用することができます。また、読み取り速度とExpectBarcodeTypesを調整することで、ノイズの多い背景からのエラーを最小限に抑えることができます。
IronBarcodeは暗号化されたPDFからのエラーをどのように処理しますか?
IronBarcodeは、暗号化されたPDFからのエラーをIronBarCodePdfPasswordExceptionを使用して処理します。これらのファイルを処理するには、PdfBarcodeReaderOptionsを使用してパスワードを供給するか、非破壊的なバーコード処理のためにログに記録しスキップします。
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。