IRONSOFTWAREHOME
ビデオ

Dynamsoft Barcode ReaderからIronBarcodeへの移行

Curtis Chau
Curtis Chau
Updated: 2026年8月1日

Dynamsoft Barcode ReaderからIronBarcodeに移行するほとんどの開発者は、Dynamsoftの評判に惹かれて選び、その後カメラ中心のAPIがドキュメント処理のユースケースに合わなかったことが発覚したグループと、ライセンスサーバーの依存性が生産事故を引き起こしたエアギャップやDocker環境での運用しているグループに分かれます。

あなたが最初のグループに属している場合、移行によって外部PDFレンダリングライブラリ、ページごとのレンダリングループ、およびエラーコードライセンスパターンが削除されます。 2番目のグループにいる場合、移行によってDockerまたはVPCの設定からInitLicenseネットワークコール、オフラインライセンスコンテンツバンドルとリフレッシュサイクル、アウトバウンドネットワークポリシーが削除されます。 いずれにせよ、この移行後にはコードベースは短くなる。

このガイドは失うものについて正直です: もしアプリケーションがリアルタイムカメラフレームを処理する場合、DynamsoftのCapture Visionパイプラインはそのワークロードに最適化されており、IronBarcodeは適切な代替ではありません。 この移行ガイドは、サーバー側でのファイル処理、ドキュメントワークフロー、およびライセンスサーバーへのアクセスに問題がある環境を対象としています。

ステップ1: NuGetパッケージを入れ替える

dotnet remove package Dynamsoft.DotNet.BarcodeReader.Bundle
dotnet add package BarCode
SHELL

プロジェクトにDynamsoft専用のPDFレンダリングライブラリ(最も一般的なのはPdfiumViewer)が追加されている場合は、それも削除できます。

# Remove if added only for Dynamsoft PDF support
dotnet remove package PdfiumViewer
dotnet remove package PdfiumViewer.Native.x86_64.v8-xfa
SHELL

ステップ2:ライセンス初期化の置き換え

ここで最も直接的な簡素化が実現する。 Dynamsoftのパターンでは、起動時に毎回エラーコードのチェックと例外処理を行う必要があります。

以前 — Dynamsoft:

using Dynamsoft.License;
using Dynamsoft.Core;

// Must run before any barcode operations
int errorCode = LicenseManager.InitLicense("YOUR-DYNAMSOFT-KEY", out string errorMsg);
if (errorCode != (int)EnumErrorCode.EC_OK)
    throw new InvalidOperationException($"License validation failed [{errorCode}]: {errorMsg}");

後 — IronBarcode:

// NuGet: dotnet add package BarCode
using IronBarCode;

// Local validation — no network call, no error code
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

ASP.NET Coreアプリケーションでは、Program.csを追加します。

IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_KEY")
    ?? "YOUR-LICENSE-KEY";

DockerまたはKubernetes環境では、デプロイマニフェストにIRONBARCODE_KEY環境変数を設定します。アウトバウンドネットワークルールは不要です。

ステップ3:名前空間インポートの置換

すべてのソースファイルに対して検索と置換を行う:

grep -r "using Dynamsoft\." --include="*.cs" .
SHELL

各出現箇所を置換します。

// Before
using Dynamsoft.CVR;
using Dynamsoft.DBR;
using Dynamsoft.License;
using Dynamsoft.Core;

// After
using IronBarCode;

コード移行の例

基本的なファイル読み取り

最も基本的な操作は、画像ファイルからバーコードを読み取ることである。

以前 — Dynamsoft:

using Dynamsoft.CVR;
using Dynamsoft.DBR;

public string ReadBarcodeFromFile(CaptureVisionRouter router, string imagePath)
{
    CapturedResult result = router.Capture(imagePath, PresetTemplate.PT_READ_BARCODES);
    BarcodeResultItem[] items = result.GetDecodedBarcodesResult()?.GetItems();
    if (items == null || items.Length == 0)
        return null;

    return items[0].GetText();
}

後 — IronBarcode:

// NuGet: dotnet add package BarCode
using IronBarCode;

public string ReadBarcodeFromFile(string imagePath)
{
    var results = BarcodeReader.Read(imagePath);
    return results?.FirstOrDefault()?.Value;
}

ルーターインスタンスは削除されました。 BarcodeReader.Readは静的です。 .Valueになります。 LINQを使用すると、resultsのnullチェックがよりクリーンになります。

複数のバーコードの読み取り

以前 — Dynamsoft:

using Dynamsoft.CVR;
using Dynamsoft.DBR;

public List<string> ReadAllBarcodes(CaptureVisionRouter router, string imagePath)
{
    SimplifiedCaptureVisionSettings settings = router.GetSimplifiedSettings(
        PresetTemplate.PT_READ_BARCODES);
    settings.BarcodeSettings.ExpectedBarcodesCount = 0; // 0 = find all
    router.UpdateSettings(PresetTemplate.PT_READ_BARCODES, settings);

    CapturedResult result = router.Capture(imagePath, PresetTemplate.PT_READ_BARCODES);
    BarcodeResultItem[] items = result.GetDecodedBarcodesResult()?.GetItems();
    var values = new List<string>();

    if (items != null)
    {
        foreach (var item in items)
            values.Add(item.GetText());
    }

    return values;
}

後 — IronBarcode:

using IronBarCode;

public List<string> ReadAllBarcodes(string imagePath)
{
    var options = new BarcodeReaderOptions
    {
        ExpectMultipleBarcodes = true,
        MaxParallelThreads = 4
    };

    return BarcodeReader.Read(imagePath, options)
        .Select(r => r.Value)
        .ToList();
}

バイト(メモリ上のイメージ)からの読み込み

以前 — Dynamsoft:

using Dynamsoft.CVR;
using Dynamsoft.Core;
using Dynamsoft.DBR;

// Requires width, height, stride, and pixel format — low-level buffer API
public string ReadFromBuffer(CaptureVisionRouter router, byte[] rawPixels, int width, int height)
{
    var imageData = new ImageData
    {
        Bytes = rawPixels,
        Width = width,
        Height = height,
        Stride = width * 3, // assuming 24bpp RGB
        Format = EnumImagePixelFormat.IPF_RGB_888
    };

    CapturedResult result = router.Capture(imageData, PresetTemplate.PT_READ_BARCODES);
    return result.GetDecodedBarcodesResult()?.GetItems()?.FirstOrDefault()?.GetText();
}

後 — IronBarcode:

using IronBarCode;

// Pass PNG/JPEG/BMP bytes directly — no pixel format or stride calculation
public string ReadFromImageBytes(byte[] imageBytes)
{
    return BarcodeReader.Read(imageBytes)?.FirstOrDefault()?.Value;
}

アプリケーションが以前に画像バイトを Dynamsoft 用の生ピクセルバッファに変換していた場合、最初に生ピクセルにデコードすることなく、元のエンコードされた画像バイト (PNG、JPEG、BMP) を直接IronBarcodeに渡すことができます。

PDFバーコード読み取り — レンダリングループの削除

これは通常、移行における最大のコード削減となる。 PdfiumViewerのレンダリングループ全体を削除し、単一の呼び出しに置き換えます。

以前 — DynamsoftとPdfiumViewer:

// Requires: Dynamsoft.DotNet.BarcodeReader.Bundle + PdfiumViewer + PdfiumViewer.Native.*
using Dynamsoft.CVR;
using Dynamsoft.DBR;
using PdfiumViewer;
using System.Drawing.Imaging;

public List<string> ReadBarcodesFromPdf(CaptureVisionRouter router, string pdfPath)
{
    var allBarcodes = new List<string>();

    using (var pdfDoc = PdfDocument.Load(pdfPath))
    {
        for (int page = 0; page < pdfDoc.PageCount; page++)
        {
            using var image = pdfDoc.Render(page, 300, 300, true);
            using var ms = new MemoryStream();
            image.Save(ms, ImageFormat.Png);

            CapturedResult result = router.Capture(ms.ToArray(),
                PresetTemplate.PT_READ_BARCODES);
            var items = result.GetDecodedBarcodesResult()?.GetItems();
            if (items != null)
            {
                foreach (var item in items)
                    allBarcodes.Add(item.GetText());
            }
        }
    }

    return allBarcodes;
}

後 — IronBarcode:

using IronBarCode;

public List<string> ReadBarcodesFromPdf(string pdfPath)
{
    return BarcodeReader.Read(pdfPath)
        .Select(r => r.Value)
        .ToList();
}

ページループ、PdfDocument、300DPIレンダーステップ、MemoryStream、およびページごとのCapture呼び出しはすべて消えます。 IronBarcodeはPDFページを内部的に処理します。

PDFからオプション付きで読み込む必要がある場合(高密度または読み取りにくいバーコードの場合):

using IronBarCode;

public List<string> ReadBarcodesFromPdfAccurate(string pdfPath)
{
    var options = new BarcodeReaderOptions
    {
        Speed = ReadingSpeed.Balanced,
        ExpectMultipleBarcodes = true
    };

    return BarcodeReader.Read(pdfPath, options)
        .Select(r => r.Value)
        .ToList();
}

オフライン/エアギャップ展開

現在のコードにオフラインライセンスパターンが含まれている場合は、それを完全に削除してください。

以前 — Dynamsoft オフラインライセンス:

using Dynamsoft.License;
using Dynamsoft.Core;

// Dynamsoft offline: fetch license bundle on a connected machine, persist it,
// then replay it on the offline machine via InitLicenseFromLicenseContent.
int errorCode = LicenseManager.InitLicenseFromLicenseContent(
    licenseContent,
    out string errorMsg);

if (errorCode != (int)EnumErrorCode.EC_OK)
    throw new InvalidOperationException($"Offline license failed: {errorMsg}");

後 — IronBarcode:

// Remove all of the above. Replace with:
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

取得して更新するライセンスコンテンツバンドルはありません。 接続済みマシンのブートストラップステップはありません。キーはローカルでの検証が行われます。

Dockerの設定

以前にDynamsoftのライセンスエンドポイントに向けたアウトバウンドHTTPSを許可するネットワーク送信ルールやプロキシ構成が必要だった場合:

# Before: Docker or Kubernetes egress policy
# Required: Allow outbound HTTPS to Dynamsoft licence endpoints

# After: Remove that egress rule.
# IronBarcode does not require outbound network access for license validation.

# Set license via environment variable
env:
  - name: IRONBARCODE_KEY
    valueFrom:
      secretKeyRef:
        name: ironbarcode-license
        key: key
Text

インスタンス管理のクリーンアップ

DynamsoftはCaptureVisionRouterを中心に構築されたインスタンスベースのAPIを使用しています。 コードがサービスクラスにルーターインスタンスを作成したり、フィールドイニシャライザーやDI登録に使っていた場合、そのすべてが消えます。

以前 — Dynamsoftインスタンス管理:

using Dynamsoft.CVR;
using Dynamsoft.DBR;
using Dynamsoft.License;
using Dynamsoft.Core;

public class BarcodeService : IDisposable
{
    private readonly CaptureVisionRouter _router;

    public BarcodeService()
    {
        int errorCode = LicenseManager.InitLicense("KEY", out string errorMsg);
        if (errorCode != (int)EnumErrorCode.EC_OK)
            throw new InvalidOperationException(errorMsg);

        _router = new CaptureVisionRouter();

        var settings = _router.GetSimplifiedSettings(PresetTemplate.PT_READ_BARCODES);
        settings.BarcodeSettings.ExpectedBarcodesCount = 0;
        _router.UpdateSettings(PresetTemplate.PT_READ_BARCODES, settings);
    }

    public string[] ReadFile(string path)
    {
        CapturedResult result = _router.Capture(path, PresetTemplate.PT_READ_BARCODES);
        var items = result.GetDecodedBarcodesResult()?.GetItems();
        return items?.Select(i => i.GetText()).ToArray() ?? Array.Empty<string>();
    }

    public void Dispose()
    {
        _router?.Dispose();
    }
}

後 — IronBarcode静的 API:

// NuGet: dotnet add package BarCode
using IronBarCode;

public class BarcodeService
{
    // No constructor initialization — license set once at app startup
    // No Dispose — no instance to clean up

    public string[] ReadFile(string path)
    {
        var options = new BarcodeReaderOptions { ExpectMultipleBarcodes = true };
        return BarcodeReader.Read(path, options)
            .Select(r => r.Value)
            .ToArray();
    }
}

クラスはそのコンストラクタ、_routerフィールドを失います。 このサービスがDIとしてシングルトンあるいはスコープドサービスとして登録されてルーターライフサイクルを管理していた場合、その登録が簡素化されたり、サービスが一連の静的メソッドになることもあります。

読書速度とタイムアウトマッピングの関係

Dynamsoftはミリ秒単位でカメラのフレームレートに最適化されたTimeoutを使用しています。 IronBarcodeはReadingSpeed列挙型を使用します:

Dynamsoftの設定IronBarcode相当品
settings.Timeout = 100 (カメラパイプライン)Speed = ReadingSpeed.Faster
タイムアウト時間を短くする(速度を優先する)Speed = ReadingSpeed.Balanced
タイムアウト時間を長くする(精度を優先する)Speed = ReadingSpeed.Detailed
最高の精度、時間的プレッシャーなしSpeed = ReadingSpeed.ExtremeDetail

スループットがサブ100ms応答時間よりも重要なほとんどのドキュメント処理ワークフローでは、ReadingSpeed.Balancedが適切なデフォルトです:

var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};

よくある移行の問題

BarcodeResultItem.GetText() vs result.Value

アクセッサはメソッドからプロパティに変わります:

// Before
string value = item.GetText();

// After
string value = result.Value;

BarcodeResultItem.GetFormatString() vs result.Format

DynamsoftはGetFormatString()を介してフォーマットを文字列として返します。 IronBarcodeはBarcodeEncoding列挙型としてこれを公開します:

// Before
if (item.GetFormatString() == "QR_CODE")
    Console.WriteLine("Found QR code");

// After
if (result.Format == BarcodeEncoding.QRCode)
    Console.WriteLine("Found QR code");

// For logging without enum comparison — .ToString() works on both
Console.WriteLine($"Format: {result.Format}");

null 結果と空のコレクション

Dynamsoftのnullを返すことができます。 IronBarcodeは空のコレクションを返します。 nullチェックの更新:

// Before: null check required
CapturedResult result = router.Capture(path, PresetTemplate.PT_READ_BARCODES);
var items = result.GetDecodedBarcodesResult()?.GetItems();
if (items != null && items.Length > 0)
    Process(items[0].GetText());

// After: null-safe but also correct to check Count
var results = BarcodeReader.Read(path);
if (results.Any())
    Process(results.First().Value);

SimplifiedCaptureVisionSettings to BarcodeReaderOptions

GetSimplifiedSettings / BarcodeReaderOptionsになります:

// Before
var settings = router.GetSimplifiedSettings(PresetTemplate.PT_READ_BARCODES);
settings.BarcodeSettings.ExpectedBarcodesCount = 0;
settings.Timeout = 500;
router.UpdateSettings(PresetTemplate.PT_READ_BARCODES, settings);
var result = router.Capture(path, PresetTemplate.PT_READ_BARCODES);

// After
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true
};
var results = BarcodeReader.Read(path, options);

移行チェックリスト

以下の検索を実行して、更新が必要なすべての Dynamsoft リファレンスを見つけてください。

grep -r "using Dynamsoft\." --include="*.cs" .
grep -r "LicenseManager.InitLicense\|EnumErrorCode\|EC_OK" --include="*.cs" .
grep -r "new CaptureVisionRouter\|router\.Capture\|PresetTemplate" --include="*.cs" .
grep -r "BarcodeResultItem\|GetDecodedBarcodesResult\|GetFormatString" --include="*.cs" .
grep -r "GetSimplifiedSettings\|UpdateSettings\|SimplifiedCaptureVisionSettings" --include="*.cs" .
grep -r "router\.Dispose\|InitLicenseFromLicenseContent" --include="*.cs" .
SHELL

各試合を順に進めてください。

  • using Dynamsoft.*using IronBarCode
  • LicenseManager.InitLicense(key, out errorMsg) + エラーチェック → IronBarCode.License.LicenseKey = "key"
  • new CaptureVisionRouter() → 削除 (静的API、インスタンスなし)
  • router.Capture(path, PresetTemplate.PT_READ_BARCODES)BarcodeReader.Read(path)
  • router.Capture(imageData, ...) (生のピクセルバッファ) → BarcodeReader.Read(imageBytes)
  • ページごとのPDFレンダーループ + router.Capture(pageBytes, ...)BarcodeReader.Read(pdfPath)
  • BarcodeResultItem.GetText()result.Value
  • BarcodeResultItem.GetFormatString()result.Format
  • GetSimplifiedSettings(...) + UpdateSettings(...)new BarcodeReaderOptions { ... }
  • router.Dispose() → 削除
  • LicenseManager.InitLicenseFromLicenseContent(...) → 完全に削除 Dynamsoft PDF処理をサポートするためだけにPdfiumViewer NuGetパッケージを追加した場合は、それらを削除してください。
  • Docker/KubernetesのDynamsoftライセンスエンドポイント向けネットワーク送信ルールを削除
  • デプロイメント構成でIRONBARCODE_KEY環境変数を設定
Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

...
詳しく読む

関連する記事

Key in blue circle

無料の30日間トライアルキーをすぐに入手してください。

Your trial license will be sent to your email address

制限なし。100% ロック解除済み。クレジットカード不要。

bullet_checkedクレジットカードやアカウントの作成は不要です。制限なし。100% ロック解除済み。クレジットカード不要。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
無料のライブデモを予約する
Booking Badge

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。