Dynamsoft 條碼閱讀器與 IronBarcode:C# 條碼庫對比
Infragistics 條碼 vs IronBarcode:僅適用於WPF的閱讀器與平台無關的 API
Infragistics 條碼閱讀在WPF中運作。 到達那裡需要一個 BarcodeReader 實例、一個 DecodeComplete 事件處理器、一個 TaskCompletionSource<string> 以將回呼橋接到非同步程式碼中、從 URI 載入的 BitmapImage,以及您想支持的每個 Symbology 家族的按位或運算——作為第二個參數傳遞給 Decode()。 省略一個家族——例如,將 Symbology.QRCode 排除在標誌之外——那麼影像中的任何 QR 條碼將靜默返回空值。 沒有例外。 沒有警告。 只是一個空結果。
這是WPF端。在WinForms端,Infragistics.Win.UltraWinBarcode 套件包含生成控制但完全沒有閱讀器類。 如果您需要在WinForms專案中閱讀條碼,Infragistics 條碼套件中沒有可以調用的內容。 同樣適用於任何ASP.NET Core控制器、控制台工具、Azure 函式、Blazor Server 組件或 Docker 容器。 Infragistics 條碼支持存在於 UI 框架的範圍內:WPF 獲得生成和事件驅動的閱讀;WinForms僅提供生成; 其他則什麼都沒有。
這個比較檢視了這種分裂在實踐中意味著什麼,然後看看IronBarcode如何使用單個靜態 API 處理相同的工作,該 API 在每個專案型別中表現相同。
了解 Infragistics 條碼支持
Infragistics 是最具代表性的 .NET UI 組件供應商之一。 Infragistics Ultimate 套件——涵蓋條碼功能的訂閱——包括數百個控制項,適用於 WinForms、WPF、ASP.NET、Blazor 和行動裝置。已經使用 Infragistics 網格、圖表或日程安排的團隊,條碼控制項是合理的補充:他們已經支付了訂閱費。
然而,條碼支持不是一個統一的程式庫。 它是兩個具有不同功能的獨立程式集,僅部分重疊。
WinForms: UltraWinBarcode
Infragistics.Win.UltraWinBarcode 套件通過 UltraWinBarcode 類在WinForms應用程式中提供條碼生成。 API 非常簡單:
// InfragisticsWinFormsgeneration
using Infragistics.Win.UltraWinBarcode;
var barcode = new UltraWinBarcode();
barcode.Symbology = Symbology.Code128;
barcode.Data = "ITEM-12345";
barcode.SaveTo(outputPath);
// InfragisticsWinFormsgeneration
using Infragistics.Win.UltraWinBarcode;
var barcode = new UltraWinBarcode();
barcode.Symbology = Symbology.Code128;
barcode.Data = "ITEM-12345";
barcode.SaveTo(outputPath);
Imports Infragistics.Win.UltraWinBarcode
Dim barcode As New UltraWinBarcode()
barcode.Symbology = Symbology.Code128
barcode.Data = "ITEM-12345"
barcode.SaveTo(outputPath)
您設定符號、分配資料、調用 SaveTo()。 在WinForms中,僅用於生成的場景中,這適用。 Symbology 列舉涵蓋常見格式:Code128、Code39、QR、EAN13 等。
此程式集中不存在的是閱讀器。 沒有 UltraBarcodeReader 類。 沒有 Scan() 方法。 如果您嘗試在WinForms應用程式中僅使用 Infragistics.Win.UltraWinBarcode 套件閱讀條碼影像,沒有可調用的內容。
WPF:XamBarcode和BarcodeReader
WPF 端包括一個生成控制(BarcodeReader 位於 Infragistics.Controls.Barcodes,來自 Infragistics.WPF.BarcodeReader 程式集)。 閱讀器是事件驅動的,設計圍繞WPF執行緒和影像模型。
在WPF中閱讀條碼需要連結 DecodeComplete 事件,將影像載入為 BitmapSource 物件而不是文件路徑,並將回呼模式轉換為可以等待的東西如果您的程式碼是非同步的。
ASP.NET Core、控制台、Docker:無
沒有專門針對 net8.0 的 Infragistics 條碼套件,沒有WPF或WinFormsUI 程式集。ASP.NET Core專案、控制台工具、Azure Functions、Blazor Server 和 Linux Docker 容器沒有 Infragistics 條碼選項。 該程式庫與 UI 框架相關聯。
WPF閱讀模式
以下是使用 Infragistics 在WPF中實際閱讀條碼的樣子:
// InfragisticsWPFreading: event-driven, requiresWPFassemblies
using Infragistics.Controls.Barcodes;
using System.Windows.Media.Imaging;
private BarcodeReader _reader;
private TaskCompletionSource<string> _result;
public InfragisticsBarcodeService()
{
_reader = new BarcodeReader();
_reader.DecodeComplete += OnDecodeComplete;
}
public async Task<string> ReadBarcodeAsync(string imagePath)
{
_result = new TaskCompletionSource<string>();
// Load asWPFBitmapSource — not a file path
var bitmap = new BitmapImage(new Uri(imagePath, UriKind.Absolute));
// Build the Symbology flags. The enum is [Flags];
// EAN-8/EAN-13/UPC-A/UPC-E share a single EanUpc flag,
// and Code 39 is exposed as Code39Ext. Use Symbology.All
// to search every supported family.
var symbologies = Symbology.Code128 |
Symbology.Code39Ext |
Symbology.QRCode |
Symbology.EanUpc |
Symbology.Interleaved2Of5;
// Symbology is the second argument to Decode/DecodeAsync,
// not a property on the reader. Result comes via callback.
_reader.DecodeAsync(bitmap, symbologies);
return await _result.Task;
}
private void OnDecodeComplete(object sender, ReaderDecodeArgs e)
{
_result?.TrySetResult(e.SymbolFound ? e.Value : "No barcode found");
}
public void Dispose()
{
if (_reader != null)
{
_reader.DecodeComplete -= OnDecodeComplete;
_reader = null;
}
}
// InfragisticsWPFreading: event-driven, requiresWPFassemblies
using Infragistics.Controls.Barcodes;
using System.Windows.Media.Imaging;
private BarcodeReader _reader;
private TaskCompletionSource<string> _result;
public InfragisticsBarcodeService()
{
_reader = new BarcodeReader();
_reader.DecodeComplete += OnDecodeComplete;
}
public async Task<string> ReadBarcodeAsync(string imagePath)
{
_result = new TaskCompletionSource<string>();
// Load asWPFBitmapSource — not a file path
var bitmap = new BitmapImage(new Uri(imagePath, UriKind.Absolute));
// Build the Symbology flags. The enum is [Flags];
// EAN-8/EAN-13/UPC-A/UPC-E share a single EanUpc flag,
// and Code 39 is exposed as Code39Ext. Use Symbology.All
// to search every supported family.
var symbologies = Symbology.Code128 |
Symbology.Code39Ext |
Symbology.QRCode |
Symbology.EanUpc |
Symbology.Interleaved2Of5;
// Symbology is the second argument to Decode/DecodeAsync,
// not a property on the reader. Result comes via callback.
_reader.DecodeAsync(bitmap, symbologies);
return await _result.Task;
}
private void OnDecodeComplete(object sender, ReaderDecodeArgs e)
{
_result?.TrySetResult(e.SymbolFound ? e.Value : "No barcode found");
}
public void Dispose()
{
if (_reader != null)
{
_reader.DecodeComplete -= OnDecodeComplete;
_reader = null;
}
}
Imports Infragistics.Controls.Barcodes
Imports System.Windows.Media.Imaging
Imports System.Threading.Tasks
Private _reader As BarcodeReader
Private _result As TaskCompletionSource(Of String)
Public Sub New()
_reader = New BarcodeReader()
AddHandler _reader.DecodeComplete, AddressOf OnDecodeComplete
End Sub
Public Async Function ReadBarcodeAsync(imagePath As String) As Task(Of String)
_result = New TaskCompletionSource(Of String)()
' Load as WPF BitmapSource — not a file path
Dim bitmap As New BitmapImage(New Uri(imagePath, UriKind.Absolute))
' Build the Symbology flags. The enum is [Flags];
' EAN-8/EAN-13/UPC-A/UPC-E share a single EanUpc flag,
' and Code 39 is exposed as Code39Ext. Use Symbology.All
' to search every supported family.
Dim symbologies = Symbology.Code128 Or
Symbology.Code39Ext Or
Symbology.QRCode Or
Symbology.EanUpc Or
Symbology.Interleaved2Of5
' Symbology is the second argument to Decode/DecodeAsync,
' not a property on the reader. Result comes via callback.
_reader.DecodeAsync(bitmap, symbologies)
Return Await _result.Task
End Function
Private Sub OnDecodeComplete(sender As Object, e As ReaderDecodeArgs)
_result?.TrySetResult(If(e.SymbolFound, e.Value, "No barcode found"))
End Sub
Public Sub Dispose()
If _reader IsNot Nothing Then
RemoveHandler _reader.DecodeComplete, AddressOf OnDecodeComplete
_reader = Nothing
End If
End Sub
這大約是 35 行基礎設施來閱讀一個條碼。 計算實際發生的事情:
- 建立一個
BarcodeReader實例並保持存活作為一個字段。 - 在構造函式中連接一個事件處理器。
- 每次調用
ReadBarcodeAsync都會建立一個新的TaskCompletionSource<string>,分配到共享字段——這意味著該服務以目前的形式並非執行緒安全。 並發調用將覆蓋_result。 - 影像必須作為
BitmapImage從Uri載入——而不是字串文件路徑、字節陣列或流。 DecodeAsync()以非同步方式觸發事件。TaskCompletionSource連接了回呼世界和非同步/等待世界。- 當
e.SymbolFound為真時,回呼提取e.Value。 Dispose()方法必須分離事件處理器以防止記憶體洩漏。
這些邏輯都與條碼無關。 它是用於處理事件驅動設計的基礎設施。 在生產程式碼中,您還需要處理 _result.Task 永遠不會完成的情況——超時、取消令牌或避免事件永遠不會觸發的防護機制。
WinForms差距
WinForms 差距比最初看起來更加突然。 構建WinForms應用程式的團隊通常到達 Infragistics 條碼頁面時期望有對稱的體驗——在兩個 UI 框架上同時進行生成和閱讀。 他們發現 Infragistics.Win.UltraWinBarcode 完全未提供任何閱讀能力。
這不是文件的疏忽。WinForms條碼程式集被設計為生成控制。 如果您需要在WinForms應用程式中掃描條碼——例如,從使用者上傳的影像文件中讀取條碼,或從攝像頭流中解碼條碼——您無法使用 Infragistics 條碼工具完成。 您將需要完全引入一個單獨的程式庫,這時使用 Infragistics 進行生成的理由就減弱了。
不對稱性給運行混合框架專案的團隊造成了覆蓋差距。 擁有WPF桌面客戶端和WinForms桌面客戶端的團隊,即便在其他地方全都使用 Infragistics,也無法在WinForms專案中使用 Infragistics 進行條碼閱讀。
符號規格:靜默失敗模式
WPF 閱讀器中傳遞給 Decode() 的 Symbology 標誌參數應該有自己的章節,因爲它的失敗模式是靜默的:缺失的標誌會返回空結果而沒有錯誤資訊。
當您調用閱讀器時,您可以將每個您想搜索的條碼家族的或運算在一起。 支持的家族有 QR、EAN/UPC (EanUpc)、Code 39 (Code39Ext)、Code 128、MaxiCode 和 Interleaved 2 of 5——DataMatrix 完全不在這個列舉中,所以WPF閱讀器不能解碼它。 Symbology.All 涵蓋了列舉中的所有內容:
// Build flags explicitly, or use Symbology.All to search every family
var symbologies = Symbology.Code128 |
Symbology.Code39Ext |
Symbology.QRCode |
Symbology.EanUpc |
Symbology.Interleaved2Of5;
_reader.DecodeAsync(bitmap, symbologies);
// Build flags explicitly, or use Symbology.All to search every family
var symbologies = Symbology.Code128 |
Symbology.Code39Ext |
Symbology.QRCode |
Symbology.EanUpc |
Symbology.Interleaved2Of5;
_reader.DecodeAsync(bitmap, symbologies);
' Build flags explicitly, or use Symbology.All to search every family
Dim symbologies = Symbology.Code128 Or
Symbology.Code39Ext Or
Symbology.QRCode Or
Symbology.EanUpc Or
Symbology.Interleaved2Of5
_reader.DecodeAsync(bitmap, symbologies)
如果條碼影像包含 QR 程式碼且 Symbology.QRCode 不在標誌中,e.SymbolFound 返回 false,且 e.Value 為空。 解碼事件仍然會觸發。 沒有異常被拋出。 調用者收到"未找到條碼"而不知道影像是否不可讀或只是未配置。
實際上,這意味著:
- 開始設置對於開發人員測試過的格式運作良好。
- 新的條碼格式進入系統(供應商更改標籤型別,新產品線使用不同的符號系統)。
- 該家族的所有影像對於閱讀器來說靜默失敗。
- 失敗看起來和"影像沒有條碼"一樣,而不是"格式未配置"。
檢查這個問題的團隊花時間檢查影像質量,然後發現該家族從未在標誌列表中。DataMatrix 是一個更清晰案例:不存在要新增的標誌,因為WPF閱讀器根本不支持它。
IronBarcode 不需要格式參數。 它在每次讀取時自動檢測每種支持的格式。 沒有需要記住的標誌。
平台矩陣
跨平臺的能力差距是最清晰地理解架構約束的方法:
| 平臺 | Infragistics 生成 | Infragistics 閱讀 | IronBarcode 生成 | IronBarcode 閱讀 |
|---|---|---|---|---|
| WPF | XamBarcode 控制 | 條碼閱讀器(事件驅動) | 是 | 是 |
| WinForms | UltraWinBarcode | 不可用 | 是 | 是 |
| ASP.NET Core | 不可用 | 不可用 | 是 | 是 |
| 控制台 | 不可用 | 不可用 | 是 | 是 |
| Blazor 伺服器 | 不可用 | 不可用 | 是 | 是 |
| Docker/Linux | 不可用 | 不可用 | 是 | 是 |
| Azure 函式 | 不可用 | 不可用 | 是 | 是 |
這個表說明了為什麼運行超過純WPF桌面應用程式的團隊覺得 Infragistics 條碼支持不夠。 就在一個專案跨越WinForms和 ASP.NET Core——或WPF和背景工作服務的瞬間——Infragistics 條碼程式庫只涵蓋了程式碼庫的一部分。
理解IronBarcode
IronBarcode 是專門為 .NET 提供的條碼程式庫,無需依賴於 WinForms、WPF 或任何 UI 框架。 相同的 NuGet 套件、相同的命名空間和相同的 API 可以在任何 .NET 專案中使用:WinForms、WPF、ASP.NET Core、控制台、Blazor Server、Docker、Azure Functions、AWS Lambda。
// IronBarcode: identical code in WinForms, WPF, ASP.NET Core, console, Docker
// NuGet: dotnet add package BarCode
using IronBarCode;
// Read — 2 lines, any platform
var results = BarcodeReader.Read(imagePath);
return results.FirstOrDefault()?.Value ?? "No barcode found";
// IronBarcode: identical code in WinForms, WPF, ASP.NET Core, console, Docker
// NuGet: dotnet add package BarCode
using IronBarCode;
// Read — 2 lines, any platform
var results = BarcodeReader.Read(imagePath);
return results.FirstOrDefault()?.Value ?? "No barcode found";
Imports IronBarCode
' Read — 2 lines, any platform
Dim results = BarcodeReader.Read(imagePath)
Return If(results.FirstOrDefault()?.Value, "No barcode found")
BarcodeReader.Read() 是一個靜態方法。 沒有需要管理的實例,沒有需要連接的事件,沒有 TaskCompletionSource 用於橋接回調模式。 它接受字串文件路徑、字節陣列、Stream 或它們的陣列進行批次處理。
對於生成,BarcodeWriter.CreateBarcode() 返回一個可以保存為 PNG、JPEG、SVG 的條碼物件,或者以二進位資料格式獲取:
using IronBarCode;
// Generate Code 128
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.SaveAsPng("barcode.png");
// Generate QR code
QRCodeWriter.CreateQrCode("https://example.com", 500,
QRCodeWriter.QrErrorCorrectionLevel.Highest)
.SaveAsPng("qr.png");
using IronBarCode;
// Generate Code 128
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.SaveAsPng("barcode.png");
// Generate QR code
QRCodeWriter.CreateQrCode("https://example.com", 500,
QRCodeWriter.QrErrorCorrectionLevel.Highest)
.SaveAsPng("qr.png");
Imports IronBarCode
' Generate Code 128
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128) _
.ResizeTo(400, 100) _
.SaveAsPng("barcode.png")
' Generate QR code
QRCodeWriter.CreateQrCode("https://example.com", 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
.SaveAsPng("qr.png")
許可初始設置在應用程式啟動時進行,一次:
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
Imports IronBarCode
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"
並排:批次處理
批次處理揭示了 InfragisticsWPF閱讀器的另一個結構限制。 由於閱讀器使用共享事件處理器且 _result 字段在每次調用時被覆蓋,上方顯示的服務類不能安全地並行處理多個影像。 您必須按順序調用:
// Infragistics: must process sequentially — shared event handler and TaskCompletionSource
// field mean concurrent calls would overwrite _result before the previous decode completes
var service = new InfragisticsBarcodeService();
var results = new List<string>();
foreach (var file in imageFiles)
{
// Each call must await before starting the next
var value = await service.ReadBarcodeAsync(file);
results.Add(value);
}
// Infragistics: must process sequentially — shared event handler and TaskCompletionSource
// field mean concurrent calls would overwrite _result before the previous decode completes
var service = new InfragisticsBarcodeService();
var results = new List<string>();
foreach (var file in imageFiles)
{
// Each call must await before starting the next
var value = await service.ReadBarcodeAsync(file);
results.Add(value);
}
Imports System.Collections.Generic
Imports System.Threading.Tasks
' Infragistics: must process sequentially — shared event handler and TaskCompletionSource
' field mean concurrent calls would overwrite _result before the previous decode completes
Dim service As New InfragisticsBarcodeService()
Dim results As New List(Of String)()
For Each file In imageFiles
' Each call must await before starting the next
Dim value As String = Await service.ReadBarcodeAsync(file)
results.Add(value)
Next
使此並行需要顯著的額外基礎結構:鎖、隊列或信號量以確保 _result 在之前的解碼仍在執行時不被覆蓋。 對於應該是簡單的I/O操作的非平凡並發問題。
IronBarcode 的靜態 BarcodeReader.Read() 是執行緒安全的。 它可以同時從多個執行緒調用而不需要任何額外的同步。 對於批次工作負載,您可以直接使用 Parallel.ForEach:
using IronBarCode;
// IronBarcode: parallel batch with thread-safe static API
var results = new System.Collections.Concurrent.ConcurrentBag<string>();
Parallel.ForEach(imageFiles, file =>
{
var barcodeResults = BarcodeReader.Read(file);
foreach (var result in barcodeResults)
{
results.Add(result.Value);
}
});
using IronBarCode;
// IronBarcode: parallel batch with thread-safe static API
var results = new System.Collections.Concurrent.ConcurrentBag<string>();
Parallel.ForEach(imageFiles, file =>
{
var barcodeResults = BarcodeReader.Read(file);
foreach (var result in barcodeResults)
{
results.Add(result.Value);
}
});
Imports IronBarCode
Imports System.Collections.Concurrent
Imports System.Threading.Tasks
' IronBarcode: parallel batch with thread-safe static API
Dim results As New ConcurrentBag(Of String)()
Parallel.ForEach(imageFiles, Sub(file)
Dim barcodeResults = BarcodeReader.Read(file)
For Each result In barcodeResults
results.Add(result.Value)
Next
End Sub)
您還可以在一次調用中傳遞多個文件並通過 BarcodeReaderOptions 配置並行性:
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
MaxParallelThreads = 4
};
var results = BarcodeReader.Read(imageFiles, options);
foreach (var result in results)
{
Console.WriteLine($"{result.Value} ({result.Format})");
}
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
MaxParallelThreads = 4
};
var results = BarcodeReader.Read(imageFiles, options);
foreach (var result in results)
{
Console.WriteLine($"{result.Value} ({result.Format})");
}
Imports IronBarCode
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True,
.MaxParallelThreads = 4
}
Dim results = BarcodeReader.Read(imageFiles, options)
For Each result In results
Console.WriteLine($"{result.Value} ({result.Format})")
Next
特性比較
| 特性 | Infragistics 條碼 | IronBarcode |
|---|---|---|
| WinForms 條碼閱讀 | 不可用 | 是 |
| WPF 條碼閱讀 | 是(事件驅動) | 是(同步) |
| ASP.NET Core 支援 | 不可用 | 是 |
| 控制台/工作服務 | 不可用 | 是 |
| Docker/Linux | 不可用 | 是 |
| Azure 函式 | 不可用 | 是 |
| Blazor 伺服器 | 不可用 | 是 |
| 自動格式檢測 | 否——必須將符號標誌傳遞給 Decode() | 是——格式自動檢測 |
| PDF 條碼讀取 | 不可用 | 是——本地,無需額外的包 |
| 執行緒安全閱讀 | 否(共享事件處理器) | 是(靜態 API) |
| 需要事件驅動 API | 是(WPF) | 否 |
| 顯式影像載入(BitmapSource) | 是 | 否——接受文件路徑、字節、流 |
| 同步閱讀 | 否(必須通過 TaskCompletionSource 進行橋接) | 是 |
| 批次處理 | 僅序列(並發不安全) | 內建平行化 |
| 靜默格式失敗 | 是(省略符號家族) | 否 |
| 需要套件依賴 | 是——Infragistics Ultimate 訂閱 | 否——獨立包 |
| 永久授權選項 | 否——年度訂閱 | 是 |
| 大約許可成本 | 年度訂閱(Infragistics Ultimate) | 從$749永久(Lite) |
API對映參考
WinForms(UltraWinBarcode) to IronBarcode
| InfragisticsWinForms—UltraWinBarcode | IronBarcode |
|---|---|
new UltraWinBarcode() |
BarcodeWriter.CreateBarcode(data, encoding) |
barcode.Symbology = Symbology.Code128 |
BarcodeEncoding.Code128(參數傳遞至 CreateBarcode) |
barcode.Data = "ITEM-12345" |
CreateBarcode() 的第一個參數 |
barcode.SaveTo(outputPath) |
.SaveAsPng(outputPath) |
| 不存在閱讀 API | BarcodeReader.Read(imagePath) |
WPF(BarcodeReader) to IronBarcode
| InfragisticsWPF— BarcodeReader | IronBarcode |
|---|---|
new BarcodeReader() |
靜態類 — 無需實例 |
_reader.DecodeComplete += OnDecodeComplete |
不需要 |
_reader.DecodeAsync(bitmap, Symbology.X |Symbology.Y) |
自動檢測 — 無需配置 |
new BitmapImage(new Uri(path)) + _reader.Decode(bitmap, ...) |
BarcodeReader.Read(path) |
e.Value (位於 ReaderDecodeArgs 中) |
result.Value |
e.Symbology (位於 ReaderDecodeArgs 中) |
result.Format |
TaskCompletionSource<string> 非同步包裝器 |
同步 — 不需要包裝器 |
Dispose() — 解除事件處理器 |
不需要 — 無實例或事件 |
| 僅WPF專案 | 任何 .NET 專案型別 |
當團隊轉換
幾個特定情況持續驅使團隊放棄 Infragistics 條碼支持。
WinForms 中需要閱讀。這是最常見的情景。WinForms應用程式使用 UltraWinBarcode 可以很好地生成條碼,但隨後出現新需求:從上傳的影像中掃一個條碼或在列印之前驗證標籤。WinForms沒有 Infragistics 閱讀 API。 團隊要麼引入第二個程式庫,要麼替換生成程式碼為可進行兩者的東西。
新的ASP.NET Core端點。 使用 Infragistics 條碼生成的桌面應用程式有一個伴侶網頁 API。 該端點需要接受影像上傳並返回條碼值,或按需生成條碼影像。 在ASP.NET Core專案中不可能使用 Infragistics 條碼包完成這些。IronBarcode使用 dotnet add package BarCode 安裝,並在控制器行動中工作方式與在控制台方法中完全一樣。
Docker 部署。 一個WPF應用正在被容器化或其條碼邏輯正被提取為微服務。WPF 程式集無法在 Linux Docker 容器中運行。 InfragisticsWPFBarcodeReader 跟隨它們一起。IronBarcode原生支援 Linux x64。
批次處理性能。 一個工作流程處理數百或數千的條碼影像。 事件驅動的 Infragistics 閱讀器按順序處理它們。IronBarcode的靜態讀者是執行緒安全的,並支持 Parallel.ForEach 或其內建的 MaxParallelThreads 選項而無需任何並發基礎結構。
生產環境中的靜默格式失敗。 一個團隊發現某個家族的條碼已經靜默失敗了幾週,因為傳遞給 Decode() 的 Symbology 標誌沒有包含那個家族。 切換到自動檢測完全消除了失敗模式。
減少 Infragistics 訂閱範圍。 一些團隊支付 InfragisticsUltimate 訂閱價格,特別因為條碼控制與之相關。 當條碼需求是訂閱的唯一原因時,相比於成本的一部分,值得評估使用一個專用的條碼程式庫。
結論
Infragistics 條碼支持的中心問題是架構上的,而不是能力相關的。WPFBarcodeReader 能夠閱讀條碼。WinFormsUltraWinBarcode 能夠生成它們。 在每個元件被設計的狹窄背景下,它們運行。 問題是這兩個背景沒有涵蓋大多數 .NET 團隊實際需要的。
一個現代 .NET 應用程式中的條碼功能很少只存在於單一的 UI 框架中。 它出現在WinForms客戶端和網頁 API 中。 它運行於 Docker 容器和桌面。它需要掃描上傳到 ASP.NET 端點的影像並從控制台工具列印標籤。 Infragistics 條碼套件中的任何部分均無法運行,且WPF閱讀器的事件驅動模式與所需的符號標誌即使在其運行的唯一背景中也會增加顯著複雜性。
IronBarcode 使用靜態 API 解決相同的問題——閱讀和生成條碼——它在每個 .NET 專案型別中編譯並運行完全相同。 您在WPF服務類中編寫的 BarcodeReader.Read() 調用,與您在ASP.NET Core控制器中編寫的調用相同,與您在 Linux Docker 容器中編寫的調用相同。 沒有事件,沒有標誌,沒有 TaskCompletionSource。 條碼邏輯是兩行而不是三十五行,且這兩行在任何地方都可以運行。
常見問題
什麼是 Infragistics Barcode?
Infragistics Barcode 是一個 .NET 條碼程式庫,用於在 C# 應用程式中生成和讀取條碼。它是開發者在為 .NET 專案選擇條碼解決方案時評估的多個替代方案之一。
Infragistics Barcode 和 IronBarcode 之間的主要差異是什麼?
IronBarcode 使用靜態、無狀態的 API,不需要實例管理,而 Infragistics Barcode 通常需要在使用前建立和配置實例。IronBarcode 還提供原生的 PDF 支援、自動格式檢測以及跨所有環境的單一密鑰授權。
IronBarcode 比 Infragistics Barcode 更容易授權嗎?
IronBarcode使用一個覆蓋開發和生產部署的單一授權金鑰。相比於將SDK金鑰與運行時金鑰分開的授權系統,這簡化了CI/CD管道和Docker配置。
IronBarcode 支援所有 Infragistics Barcode 支援的條碼格式嗎?
IronBarcode支持超過30種條碼符號,包括QR Code、Code 128、Code 39、DataMatrix、PDF417、Aztec、EAN-13、UPC-A、GS1等。格式自動檢測意味著不需要顯式的格式枚舉。
IronBarcode支持原生PDF條碼讀取嗎?
是的。IronBarcode可以直接從PDF文件中讀取條碼,使用BarcodeReader.Read("document.pdf"),無需單獨的PDF渲染程式庫。每頁結果包括頁碼、條碼格式、值和置信分數。
IronBarcode 與 Infragistics Barcode 相比如何處理批量處理?
IronBarcode的靜態方法無狀態且天然執行緒安全,可以直接使用Parallel.ForEach而無需每個執行緒的實例管理。任何價格級別下都沒有吞吐量上限。
IronBarcode支持哪些.NET版本?
IronBarcode支持.NET Framework 4.6.2+、.NET Core 3.1,以及.NET 5、6、7、8和9,單一NuGet包。平台目標包括Windows x64/x86、Linux x64和macOS x64/ARM。
如何在.NET專案中安裝IronBarcode?
通過NuGet安裝IronBarcode:在Package Manager Console中運行 'Install-Package IronBarCode',或在CLI中運行 'dotnet add package IronBarCode'。不需要額外的SDK安裝程式或運行時文件。
與 Infragistics 不同,我可以在購買之前評估 IronBarcode 嗎?
可以。IronBarcode的試用模式返回完整解碼的條碼值——只有生成的輸出圖像上有水印。您可以在自己的文件上評估讀取準確性,然後再決定購買。
Infragistics Barcode 和 IronBarcode 之間的價差是多少?
IronBarcode起價為$749,為單開發者所適用的永久授權,覆蓋開發和生產。價格詳情和批量選項可在IronBarcode授權頁面獲得。無需單獨的運行時授權。
從 Infragistics Barcode 遷移到 IronBarcode 很簡單嗎?
從 Infragistics Barcode 遷移到 IronBarcode 主要涉及將基於實例的 API 調用替換為 IronBarcode 的靜態方法,刪除授權樣板程式碼,以及更新結果屬性名稱。大多數遷移涉及減少程式碼而不是增加。
IronBarcode可以生成帶有Logo的QR碼嗎?
可以。QRCodeWriter.CreateQrCode().AddBrandLogo("logo.png") 可以原生嵌入品牌圖像進QR碼,並可配置錯誤更正。也支持通過ChangeBarCodeColor() 生成彩色QR碼。

