Infragistics Barcode 與 IronBarcode:C# 條碼庫對比
Infragistics 條碼讀取功能可在WPF中運作。 要實現這一點,需要一個 BarcodeReader 實例、一個 DecodeComplete 事件處理程序、一個 TaskCompletionSource<string> 將回調橋接到異步代碼、一個 @@--CODE@93875--@@ 將回調橋接到異步代碼、一個 @@--CODE@93875--進行顯式位元或運算。 漏掉一個標誌(例如 SymbologyType.EAN8),影像中的任何 EAN-8 條碼都會默默地傳回空值。 沒有例外。 沒有預警。 結果為空。
這是WPF部分。在WinForms部分,Infragistics.Win.UltraWinBarcode 套件包含生成控件,但完全沒有讀取器類別。 如果您需要在WinForms專案中讀取條碼,Infragistics 條碼套件中沒有任何可以呼叫的函數。 這同樣適用於任何 ASP.NET Core 控制器、控制台工具、Azure 函數、Blazor 伺服器元件或 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 端既包含生成控制項(XamBarcode),也包含單獨的讀取器類別(BarcodeReader,位於 Infragistics.Controls.Barcodes,來自 Infragistics.WPF.BarcodeReader 組件)。 此閱讀器是事件驅動的,圍繞著WPF線程和圖像模型設計。
在WPF中讀取條碼需要連接 DecodeComplete 事件,將映像載入為 BitmapSource 物件而不是檔案路徑,並且如果您的程式碼是異步的,則需要將回呼模式轉換為可等待的內容。
ASP.NET Core、主機、Docker:無
沒有適用於 net8.0 且不包含WPF或WinFormsUI 組件的 Infragistics 條碼套件。 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));
// Must specify EVERY format — no auto-detection
_reader.SymbologyTypes = SymbologyType.Code128 |
SymbologyType.Code39 |
SymbologyType.QR |
SymbologyType.EAN8 |
SymbologyType.EAN13 |
SymbologyType.UPCA |
SymbologyType.DataMatrix |
SymbologyType.Interleaved2of5;
// Trigger decode — result comes via callback
_reader.Decode(bitmap);
return await _result.Task;
}
private void OnDecodeComplete(object sender, ReaderDecodeArgs e)
{
_result?.TrySetResult(e.SymbologyValue ?? "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));
// Must specify EVERY format — no auto-detection
_reader.SymbologyTypes = SymbologyType.Code128 |
SymbologyType.Code39 |
SymbologyType.QR |
SymbologyType.EAN8 |
SymbologyType.EAN13 |
SymbologyType.UPCA |
SymbologyType.DataMatrix |
SymbologyType.Interleaved2of5;
// Trigger decode — result comes via callback
_reader.Decode(bitmap);
return await _result.Task;
}
private void OnDecodeComplete(object sender, ReaderDecodeArgs e)
{
_result?.TrySetResult(e.SymbologyValue ?? "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))
' Must specify EVERY format — no auto-detection
_reader.SymbologyTypes = SymbologyType.Code128 Or
SymbologyType.Code39 Or
SymbologyType.QR Or
SymbologyType.EAN8 Or
SymbologyType.EAN13 Or
SymbologyType.UPCA Or
SymbologyType.DataMatrix Or
SymbologyType.Interleaved2of5
' Trigger decode — result comes via callback
_reader.Decode(bitmap)
Return Await _result.Task
End Function
Private Sub OnDecodeComplete(sender As Object, e As ReaderDecodeArgs)
_result?.TrySetResult(If(e.SymbologyValue, "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載入-而不是檔案路徑字串、位元組陣列或流。 Decode()非同步觸發事件。TaskCompletionSource是回調世界和 async/await 世界之間的黏合劑。- 回調提取
e.SymbologyValue。 Dispose()方法必須分離事件處理程序以防止記憶體洩漏。
這些邏輯都與條碼無關。 這是圍繞事件驅動設計運作所需的基礎設施。 在生產代碼中,您還需要處理 _result.Task 永遠不會完成的情況—逾時、取消令牌或一些防止事件永遠不會觸發的保護措施。
WinForms差距
WinForms 與其他技術之間的差距比乍看之下要大得多。 建立WinForms應用程式的團隊經常會造訪 Infragistics 條碼頁面,希望獲得對稱的體驗——在兩個 UI 框架上產生和讀取條碼。 他們發現 Infragistics.Win.UltraWinBarcode 完全不具備讀取功能。
這不是文件記錄疏失。WinForms條碼程序集被設計為產生控制項。 如果您需要在WinForms應用程式中掃描條碼(例如,從使用者上傳的影像檔案中讀取條碼,或從相機畫面中解碼條碼),則無法使用 Infragistics 條碼工具完成此操作。 你需要引入一個完全獨立的函式庫,這樣一來,使用 Infragistics 進行產生的理由就站不住腳了。
這種不對稱性為運行混合框架專案的團隊帶來了非常尷尬的局面。 即使團隊在其他所有地方都使用了 Infragistics,但如果他們同時擁有WPF桌面用戶端和WinForms桌面用戶端,則無法在WinForms專案中使用 Infragistics 進行條碼讀取。
符號規格:一種靜默故障模式
WPF 讀取器中的 SymbologyTypes 標誌屬性值得單獨介紹,因為它的故障模式很微妙,在生產環境中也很危險。
配置閱讀器時,必須將要支援的每個條碼格式明確地按"或"關係連接起來:
// Must enumerate every format — miss one, that format silently returns empty
_reader.SymbologyTypes = SymbologyType.Code128 |
SymbologyType.Code39 |
SymbologyType.QR |
SymbologyType.EAN8 |
SymbologyType.EAN13 |
SymbologyType.UPCA |
SymbologyType.DataMatrix |
SymbologyType.Interleaved2of5;
// Must enumerate every format — miss one, that format silently returns empty
_reader.SymbologyTypes = SymbologyType.Code128 |
SymbologyType.Code39 |
SymbologyType.QR |
SymbologyType.EAN8 |
SymbologyType.EAN13 |
SymbologyType.UPCA |
SymbologyType.DataMatrix |
SymbologyType.Interleaved2of5;
' Must enumerate every format — miss one, that format silently returns empty
_reader.SymbologyTypes = SymbologyType.Code128 Or
SymbologyType.Code39 Or
SymbologyType.QR Or
SymbologyType.EAN8 Or
SymbologyType.EAN13 Or
SymbologyType.UPCA Or
SymbologyType.DataMatrix Or
SymbologyType.Interleaved2of5
如果條碼影像包含 EAN-8 條碼,且 SymbologyType.EAN8 不在標誌中,則 e.SymbologyValue 傳回 null 或空值。 解碼事件仍然會觸發。 不會拋出異常。 呼叫者收到"未找到條碼"的提示,但無法判斷影像是無法讀取還是根本沒有配置。
實際上,這意味著:
- 對於開發者測試過的格式,初始設定運作正常。
- 系統中引入了新的條碼格式(供應商更改了標籤類型,新產品線使用了不同的符號系統)。
- 對於所有這種格式的圖像,閱讀器都會默默地失敗。
- 此故障看起來與"影像沒有條碼"完全相同,而不是"格式未配置"。
調試此問題的團隊花費大量時間檢查圖像質量,才意識到該格式從未在標誌列表中。
IronBarcode 無 SymbologyTypes 屬性。 每次讀取時,它都會自動偵測所有 50 多種支援的格式。 沒有需要遺忘的旗幟。
平台矩陣
平台間的能力差距是理解架構限制的最直接方式:
| 平台 | 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 IronBarcode
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 IronBarcode
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-KEY";
IronBarCode.License.LicenseKey = "YOUR-KEY";
Imports IronBarCode
IronBarCode.License.LicenseKey = "YOUR-KEY"
並排:批量處理
批次處理暴露了 InfragisticsWPF讀取器的另一個結構性限制。 因為讀取器使用共享事件處理程序,並且每次調用都會覆蓋 _result 字段,所以上面顯示的服務類不能安全地並發處理多個圖像。 必須按順序調用:
// Infragistics: must process sequentially — shared event handler and TaskCompletionSource
// are not thread-safe; concurrent calls would corrupt _result
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
// are not thread-safe; concurrent calls would corrupt _result
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
' Infragistics: must process sequentially — shared event handler and TaskCompletionSource
' are not thread-safe; concurrent calls would corrupt _result
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 伺服器 | 無法提供 | 是 |
| 自動格式偵測 | 不——必須指定每個符號類型標誌 | 是的-所有50多種格式都能自動偵測。 |
| PDF條碼讀取 | 無法提供 | 是的-原生支持,無需額外軟體包 |
| 線程安全讀取 | 否(共享事件處理程序) | 是的(靜態 API) |
| 需要事件驅動型 API | 是的(WPF) | 無 |
| 顯式影像載入(BitmapSource) | 是 | 否——接受檔案路徑、位元組數和流。 |
| 同步閱讀 | 否(必須透過 TaskCompletionSource 進行橋接) | 是 |
| 批量處理 | 僅依序執行(不安全並發) | 內建並行化 |
| 靜默格式化失敗 | 是的(缺少 SymbologyType 標誌) | 無 |
| 套件依賴項 | 是的-Infragistics Ultimate訂閱 | 不——獨立軟體包 |
| 永久授權選項 | 不——年度訂閱 | 是 |
| 大致授權費用 | 每年 1,675 美元以上(Infragistics Ultimate) | 永久使用權(精簡版)起價 749 美元 |
API 對應參考。
WinForms(UltraWinBarcode) 到 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(條碼閱讀器)到 IronBarcode
| InfragisticsWPF— 條碼閱讀器 | IronBarcode |
|---|---|
new BarcodeReader() |
靜態類別-無需實例 |
_reader.DecodeComplete += OnDecodeComplete |
不需要 |
| `_reader.SymbologyTypes = SymbologyType.X | 符號型.Y | …… | 自動檢測-無需配置 |
new BitmapImage(new Uri(path)) + _reader.Decode(bitmap) |
BarcodeReader.Read(path) |
e.SymbologyValue(在回呼函數中) |
result.Value |
e.Symbology(在回呼函數中) |
result.Format |
TaskCompletionSource<string> 非同步包裝器 |
同步-無需包裝器 |
Dispose() — 分離事件處理程序 |
不需要-沒有實例或事件 |
| 僅限WPF項目 | 任何 .NET 專案類型 |
當球隊切換
某些特定情況總是導致團隊放棄使用 Infragistics 條碼支援。
WinForms閱讀材料需求。這是最常見的應用場景。WinForms應用程式可以正常產生條碼,例如 UltraWinBarcode,但後來出現了一個新的要求:掃描上傳圖像中的條碼或在列印前驗證標籤。 Infragistics 沒有適用於WinForms的讀取 API。 團隊要麼引入第二個函式庫,要麼用能夠同時實現這兩個功能的程式替換生成程式碼。
新增 ASP.NET Core 端點。具有 Infragistics 條碼產生功能的桌面應用程式現在擁有配套的 Web API。 此端點需要接受影像上傳並傳回條碼值,或按需產生條碼影像。 在 ASP.NET Core 專案中使用 Infragistics 條碼套件無法實現上述任何功能。IronBarcode使用 dotnet add package IronBarcode 安裝,且在控制器操作中的運作方式與在控制台方法中的運作方式相同。
Docker部署。 WPF應用程式正在被容器化,或者其條碼邏輯正在被提取到微服務中。 WPF組件無法在Linux Docker容器中運作。 InfragisticsWPFBarcodeReader 與它們一起。IronBarcode原生支援 Linux x64 系統。
批量處理性能。一個工作流程可以處理成百上千張條碼影像。 事件驅動型 Infragistics 讀取器會依序處理它們。IronBarcode的靜態讀取器是線程安全的,並且支援 Parallel.ForEach 或其內建的 MaxParallelThreads 選項,而無需任何並發基礎架構。
生產環境中出現靜默格式故障。一個團隊發現,某種格式的條碼已經靜默故障數週,原因是 SymbologyTypes 標誌未包含該格式。 切換到自動偵測模式可以徹底消除故障模式。
縮減 Infragistics 訂閱範圍。有些團隊之所以支付 Infragistics Ultimate 訂閱費用,正是因為其中包含條碼控制功能。 如果訂閱的唯一原因是需要條碼,那麼價格低廉的專用條碼庫值得考慮。
結論
Infragistics 條碼支援的核心問題是架構上的,而不是功能上的。WPFBarcodeReader 可讀取條碼。WinFormsUltraWinBarcode 會產生它們。 在每個組件所設計的特定範圍內,它們都能發揮作用。 問題在於,這兩種情況並不能涵蓋大多數 .NET 團隊實際需要的內容。
在現代 .NET 應用程式中,條碼功能很少只存在於一個 UI 框架中。 它出現在WinForms用戶端和 Web API 中。 它運行在 Docker 容器和桌面系統上。它需要掃描上傳到 ASP.NET 端點的圖像,並透過控制台工具列印標籤。 這些方法都無法與 Infragistics 條碼套件配合使用,而且WPF閱讀器的事件驅動模式以及所需的符號標誌即使在唯一能夠正常工作的上下文中也增加了很大的複雜性。
IronBarcode 解決了相同的問題——讀取和產生條碼——它使用靜態 API,可以在每種 .NET 專案類型中編譯和運行,結果都一樣。 在WPF服務類別中編寫的 BarcodeReader.Read() 呼叫與在 ASP.NET Core 控制器中編寫的呼叫相同,也與在 Linux Docker 容器中編寫的呼叫相同。 沒有事件,沒有標誌,沒有 TaskCompletionSource。 條碼邏輯只有兩行而不是三十五行,而且這兩行在任何地方都能正常運作。
常見問題解答
什麼是 Infragistics 條碼?
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 128、Code 39、DataMatrix、PDF417、Aztec、EAN-13、UPC-A、GS1 等等。格式自動偵測功能意味著無需明確枚舉格式。
IronBarcode是否支援原生PDF條碼讀取?
是的。 IronBarcode 可以直接從 PDF 檔案讀取條碼,使用 `BarcodeReader.Read("document.pdf")` 方法,無需單獨的 PDF 渲染庫。每頁的讀取結果包括頁碼、條碼格式、數值和置信度評分。
與 Infragistics Barcode 相比,IronBarcode 在批次處理方面有何不同?
IronBarcode 的靜態方法是無狀態的,且天然執行緒安全,因此可以直接使用 Parallel.ForEach,而無需進行執行緒層級實例管理。所有定價層級均無吞吐量上限。
IronBarcode支援哪些.NET版本?
IronBarcode 在單一 NuGet 套件中支援 .NET Framework 4.6.2+、.NET Core 3.1 以及 .NET 5、6、7、8 和 9。平台目標包括 Windows x64/x86、Linux x64 和 macOS x64/ARM。
如何在.NET專案中安裝IronBarcode?
透過 NuGet 安裝 IronBarcode:在程式包管理器控制台中執行“Install-Package IronBarCode”,或在命令列介面中執行“dotnet add package IronBarCode”。無需其他 SDK 安裝程式或運行時檔案。
與 Infragistics 不同,我可以在購買前評估 IronBarcode 嗎?
是的。 IronBarcode 的試用模式會傳回完整的解碼條碼值-只有產生的輸出影像才會有浮水印。您可以在購買前,用自己的文件測試讀取準確率。
Infragistics Barcode 和 IronBarcode 的價格有什麼不同?
IronBarcode 的永久單開發者許可證起價為 749 美元,涵蓋開發和生產環境。定價詳情和大量許可選項請造訪 IronBarcode 授權頁面。無需單獨的運行時許可證。
從 Infragistics Barcode 遷移到 IronBarcode 是否簡單?
從 Infragistics Barcode 遷移到 IronBarcode 主要涉及將基於實例的 API 呼叫替換為 IronBarcode 的靜態方法、移除許可相關的樣板程式碼以及更新結果屬性名稱。大多數遷移工作都是減少程式碼,而不是增加程式碼。
IronBarcode 能產生帶有 logo 的二維碼嗎?
是的。 `QRCodeWriter.CreateQrCode().AddBrandLogo("logo.png")` 可以將品牌圖片原生嵌入二維碼中,並支援設定糾錯功能。此外,它還支援透過 `ChangeBarCodeColor()` 函數建立彩色二維碼。

