MESCIUSComponentOne C1BarCodevs IronBarcode
MESCIUS ComponentOne的條碼控制(前身為GrapeCity,於2023年更名)在Windows Forms、WPF、WinUI、Blazor和ASP.NET Core MVC應用程式中生成條碼。 它能很好地完成這一工作——API清晰,輸出質量穩定,並能自然地與WinForms設計器整合。 但其功能範圍有限。 它無法讀取條碼。 WinForms和WPF版本只在Windows特定的目標框架上運行。 而且它不是一個單獨的產品——它作為ComponentOne Studio Enterprise的一部分供應,這是一項$1,299/每位開發者/每年訂閱,包括超過100個UI控制。 如果您正在評估.NET項目的條碼選項並在比較列表上找到了ComponentOne,本文將介紹該範圍在實際中的含意。
理解C1BarCode
C1BarCode是一個可視控制。 生成工作流程建立實例,設置屬性,並調用System.Drawing.Image:
// ComponentOne C1BarCode
using C1.Win.Barcode;
using C1.BarCode;
using System.Drawing;
// License must be set before first use
C1.C1License.Key = "YOUR-COMPONENTONE-KEY";
var barcode = new C1BarCode();
barcode.CodeType = CodeType.Code128;
barcode.Text = "ITEM-12345";
barcode.BarHeight = 100;
barcode.ModuleSize = 2;
barcode.ShowText = true;
barcode.CaptionPosition = CaptionPosition.Below;
using var image = barcode.GetImage();
image.Save("barcode.png", System.Drawing.Imaging.ImageFormat.Png);Imports C1.Win.Barcode
Imports C1.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging
' License must be set before first use
C1.C1License.Key = "YOUR-COMPONENTONE-KEY"
Dim barcode As New C1BarCode()
barcode.CodeType = CodeType.Code128
barcode.Text = "ITEM-12345"
barcode.BarHeight = 100
barcode.ModuleSize = 2
barcode.ShowText = True
barcode.CaptionPosition = CaptionPosition.Below
Using image As Image = barcode.GetImage()
image.Save("barcode.png", ImageFormat.Png)
End Using屬性設置API對於WinForms開發者來說很熟悉——它直接映射到設計器介面。 CaptionPosition都是在程式碼中以相同方式運行的設計器可見屬性。
C1BarCode支持38種符號涵蓋主流1D和2D格式:Code 39, Code 128, EAN-8, EAN-13, UPC-A, UPC-E, ITF, QR Code, PDF417 和 DataMatrix等。 對於條碼生成,它涵蓋了常見的使用情況。
無讀取API
這不是配置選項可以彌補的差距。 沒有C1BarCodeReader類。 Decode()方法。 ComponentOne的條碼控制按設計來說僅限於生成。
如果您的應用程式需要從上傳的圖像中掃描條碼,驗證列印標籤,處理具有嵌入程式碼的文件,或從網路API中提取QR程式碼資料——C1BarCode無法做到這一點。 您將需要一個單獨的庫來讀取,這會引發為什麼要在一個覆蓋100多個控制的企業套件中支付僅限於條碼生成的組件的費用,而獨立的條碼庫涵蓋了這兩個操作。
缺少讀取API對於設計為列印輸出的WinForms條碼控制來說並不罕見。 當需求擴大時這就成了需要考慮的問題——而條碼需求幾乎總是會擴大。
僅限於Windows
C1BarCode的WinForms和WPF版本需要Windows特定的目標框架配置:
<!-- ComponentOne WinForms edition target -->
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
UseWindowsForms不是可選的。 Graphics——而這些僅存在於Windows上。 移除net8.0-windows會導致構建失敗。 ComponentOne確實提供針對跨平台TFM的Blazor和ASP.NET Core MVC版本的條碼控制,但WinForms和WPF套件受限於Windows。
相比之下,IronBarcode的目標是net8.0(或任何支持的TFM)而沒有平台限制:
<!--IronBarcode— standard cross-platform target -->
<TargetFramework>net8.0</TargetFramework>
<!-- 否 UseWindowsForms required -->
<!-- Runs on Linux, macOS, Docker, Azure Functions -->
在幾種實際情況下這很重要:
- Linux上的Azure App Service: 新的App Service部署的預設計畫。
net8.0-windows無法定位到它。 - Docker容器: Linux容器是標準。 Windows容器更大,成本更高,並在許多雲層中不可用。
- ASP.NET Core Web API: 僅能部署到Windows的條碼生成端點是團隊最終需要移除的部署限制。
- Azure Functions: 使用量方案在Linux上運行。 具有
net8.0-windows目標的條碼生成函式無法部署到使用量方案。 - macOS開發: 使用macOS的開發者無法本地運行
net8.0-windows項目,即使用於測試生成邏輯。
如果您的應用程式是只能在Windows上運行的WinForms桌面工具,那麼平台限制不是問題。 一旦部署需求包括任何Linux或雲環境,這就成了問題。
套件綑綁
C1BarCode控制作為ComponentOne Studio Enterprise的一部分出售,該套件包括WinForms、WPF、Blazor和ASP.NET的完整ComponentOne控制套件。 ComponentOne Studio Enterprise的定價為每位開發者每年$1,299(訂閱); 單一平台版本(WinForms或WPF)為每位開發者每年$799。
該套件包括超過100個組件:網格、圖表、計劃、輸入控制、報告設計工具、地圖控制、儀表等等。 如果您正在構建一個以資料為主的應用程式並需要這些控制中的很多個,那麼套件定價可能有意義。 如果您需要條碼生成並選擇ComponentOne是因為它出現在搜索中,那麼您主要是為了一個控制購買企業UI套件。
NuGet包是C1.Blazor.BarCode),並通過ComponentOne Studio訂閱來授權。 對於希望獲得條碼功能而不需整個套件的開發者,沒有單獨的條碼專用授權級別。
IronBarcode的定價結構不同:它是一個獨立的條碼庫,以永久授權開始,單位開發者$999(Lite),三位$1,499(Plus),十位$2,399(Professional),無限開發者$4,799(Unlimited)。 沒有網格控制,沒有圖表庫,沒有報告設計器——只有您尋找的條碼功能。
QR程式碼自訂
兩個庫都支持具有自訂選項的QR程式碼生成。 API風格不同相當大。
ComponentOne屬性設置方法:
// ComponentOne — QR code with error correction and color
using C1.Win.Barcode;
using C1.BarCode;
using System.Drawing;
C1.C1License.Key = "YOUR-COMPONENTONE-KEY";
var barcode = new C1BarCode();
barcode.CodeType = CodeType.QRCode;
barcode.Text = "https://example.com/product/4821";
barcode.QRCodeVersion = QRCodeVersion.Version5;
barcode.QRCodeErrorCorrectionLevel = QRCodeErrorCorrectionLevel.High;
barcode.QRCodeModel = QRCodeModel.Model2;
barcode.ForeColor = Color.DarkBlue;
barcode.BackColor = Color.White;
barcode.ModuleSize = 4;
using var image = barcode.GetImage();
image.Save("product-qr.png", System.Drawing.Imaging.ImageFormat.Png);Imports C1.Win.Barcode
Imports C1.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging
C1.C1License.Key = "YOUR-COMPONENTONE-KEY"
Dim barcode As New C1BarCode()
barcode.CodeType = CodeType.QRCode
barcode.Text = "https://example.com/product/4821"
barcode.QRCodeVersion = QRCodeVersion.Version5
barcode.QRCodeErrorCorrectionLevel = QRCodeErrorCorrectionLevel.High
barcode.QRCodeModel = QRCodeModel.Model2
barcode.ForeColor = Color.DarkBlue
barcode.BackColor = Color.White
barcode.ModuleSize = 4
Using image As Image = barcode.GetImage()
image.Save("product-qr.png", ImageFormat.Png)
End UsingIronBarcode流暢鏈:
//IronBarcode— QR code with error correction and color
// NuGet: dotnet add package IronBarcode
using IronBarCode;
using System.Drawing;
QRCodeWriter.CreateQrCode(
"https://example.com/product/4821",
300,
QRCodeWriter.QrErrorCorrectionLevel.Highest)
.ChangeBarCodeColor(Color.DarkBlue)
.SaveAsPng("product-qr.png");Imports IronBarCode
Imports System.Drawing
QRCodeWriter.CreateQrCode( _
"https://example.com/product/4821", _
300, _
QRCodeWriter.QrErrorCorrectionLevel.Highest) _
.ChangeBarCodeColor(Color.DarkBlue) _
.SaveAsPng("product-qr.png")ComponentOne的方法需要實例化一個GetImage()。 IronBarcode的.SaveAsPng()。 沒有要管理的實例。
IronBarcode還支持在QR程式碼中嵌入徽標,而C1BarCode則不支持:
// QR code with embedded brand logo
QRCodeWriter.CreateQrCode("https://example.com/track/8821", 500)
.AddBrandLogo("company-logo.png")
.ChangeBarCodeColor(Color.DarkBlue)
.SaveAsPng("branded-qr.png");' QR code with embedded brand logo
QRCodeWriter.CreateQrCode("https://example.com/track/8821", 500) _
.AddBrandLogo("company-logo.png") _
.ChangeBarCodeColor(Color.DarkBlue) _
.SaveAsPng("branded-qr.png")理解IronBarcode
IronBarcode是一個獨立的.NET條碼庫,涵蓋生成和讀取。 它可從NuGet中安裝 (dotnet add package IronBarcode),支持任何.NET TFM而無平台限制,並在Windows、Linux、macOS、Docker、Azure和AWS Lambda上運行。
讀取部分原生支持PDF文件:
// Read barcodes from a PDF — no image extraction needed
using IronBarCode;
var results = BarcodeReader.Read("invoice.pdf");
foreach (var barcode in results)
{
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}");
}Imports IronBarCode
' Read barcodes from a PDF — no image extraction needed
Dim results = BarcodeReader.Read("invoice.pdf")
For Each barcode In results
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}")
Next對於高吞吐量場景,BarcodeReaderOptions控制速度與準確性的權衡及多條碼檢測:
// Multi-barcode read with performance options
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode
};
var results = BarcodeReader.Read("warehouse-manifest.jpg", options);Imports IronBarCode
' Multi-barcode read with performance options
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True,
.ExpectBarcodeTypes = BarcodeEncoding.Code128 Or BarcodeEncoding.QRCode
}
Dim results = BarcodeReader.Read("warehouse-manifest.jpg", options)生成涵蓋標準格式,具有一致的靜態API:
// Code 128 generation to file
BarcodeWriter.CreateBarcode("SHIP-20240312-7834", BarcodeEncoding.Code128)
.SaveAsPng("shipping-label.png");
//QR碼生成to byte array (for HTTP response)
byte[] qrBytes = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400)
.ToPngBinaryData();
支持的平台:Windows、Linux、macOS、Docker、Azure(App Service和Functions)、AWS Lambda。 支持的.NET版本:.NET Framework 4.6.2+,.NET Core 3.1+,以及.NET 5/6/7/8。
特性比較
| 特性 | MESCIUSComponentOne C1BarCode | IronBarcode |
|---|---|---|
| 條碼生成 | 是 | 是 |
| 條碼讀取 | 否 | 是 |
| QR碼生成 | 是 | 是 |
| QR 標誌嵌入 | 否 | 是 |
| PDF讀取輸入 | 不適用(無讀取) | 是的(原生) |
| .NET平台目標(WinForms/WPF版) | net8.0-windows | 任何TFM(net8.0等) |
| 需要UseWindowsForms(WinForms版) | 是 | 否 |
| Linux / Docker部署 | 僅限Blazor/ASP.NET MVC版 | 是 |
| macOS部署 | 僅限Blazor/ASP.NET MVC版 | 是 |
| Azure Functions(Linux) | 僅限Blazor/ASP.NET MVC版 | 是 |
| ASP.NET Core伺服器端 | ASP.NET Core MVC版 | 是 |
| 獨立NuGet包 | 套件授權包 | 是 |
| 獨立定價 | 不適用 | 從$999永久(Lite) |
| 套件定價 | $1,299/開發者/年Enterprise;$799/開發者/年單一平台 | 不適用 |
| 流暢生成API | 否(屬性設置) | 是 |
BarcodeReader.Read() | 否 | 是 |
BarcodeWriter.CreateBarcode() | 否 | 是 |
QRCodeWriter.CreateQrCode() | 否 | 是 |
| 支持的.NET版本 | .NET 6+(WinForms/WPF的Windows) | .NET Framework 4.6.2+, .NET Core 3.1+, .NET 5–8 |
| 永久授權選項 | 否(訂閱) | 是 |
API對映參考
對於從C1BarCode遷移到IronBarcode的團隊,這些直接等效適用:
| ComponentOne C1BarCode | IronBarcode |
|---|---|
C1.C1License.Key = "..." | IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY" |
new C1BarCode() | 靜態——無需實例 |
barcode.CodeType = CodeType.Code128 | BarcodeEncoding.Code128(作為參數傳遞) |
barcode.Text = "data" | BarcodeWriter.CreateBarcode()的第一個參數 |
barcode.BarHeight = 100 | .ResizeTo(width, 100)在條碼編寫器上 |
barcode.ModuleSize = 2 | .ResizeTo()控制以像素為單位的大小 |
barcode.ForeColor = Color.DarkBlue | .ChangeBarCodeColor(Color.DarkBlue) |
barcode.BackColor = Color.White | .ChangeBackgroundColor(Color.White) |
barcode.GetImage() | .SaveAsPng() / .ToPngBinaryData() |
barcode.QRCodeErrorCorrectionLevel | QRCodeWriter.QrErrorCorrectionLevel枚舉 |
barcode.QRCodeVersion | 自動(或版本參數) |
| 無讀取API | BarcodeReader.Read(path) |
net8.0-windows需要 | net8.0(或任何TFM) |
UseWindowsForms = true需要 | 不需要 |
當團隊轉換
讀取需求出現。 這是最常見的觸發器。 一個團隊用C1BarCode建構條碼標籤生成,然後有要求驗證掃描、處理入站的運輸文件或從上傳圖像解碼QR程式碼。 C1BarCode幫不上忙。選擇是:新增第二個條碼庫來讀取,或者用能處理這兩者的庫替代C1BarCode。
Linux或Docker部署。 發布到Windows桌面的WinForms桌面應用程式不面臨這種限制。 一個ASP.NET Core API生成條碼圖像確實這樣做——特別是當它需要運行在Linux容器中或部署到Linux上的Azure App Service時。 net8.0-windows目標框架立即阻擋了這些部署選項。
微服務或無伺服器架構。 Azure Functions、AWS Lambda和容器化微服務是Linux優先。無法部署到Linux的條碼生成服務不是可行的微服務。
套件訂閱成本與需求範圍。 那些為ComponentOne Studio Enterprise支付費用並且已經使用其網格、圖表和其他控件的團隊已經證明了訂閱的合理性。 主要或完全為條碼生成而訂閱的團隊正在為他們不使用的100多個控件支付費用。 每位開發者的訂閱成本隨團隊規模增加。
永久授權偏好。 ComponentOne Studio僅限於訂閱。 沒有永久授權選項。 對於那些希望擁有他們發布的軟體的團隊——特別是出於合規性或長期維護原因——IronBarcode的永久授權(從$999 Lite開始)結構上有所不同。
結論
C1BarCode在WinForms上下文中乾淨地生成條碼。 這確實是它擅長的事情,對於僅需要在Windows上進行標籤生成的WinForms桌面應用程式來說,這是ComponentOne套件內功能選擇。
範圍僅止於此。 無讀取,僅限Windows部署,無獨立包,訂閱授權。 當項目需求超出Windows上的WinForms生成時——一個讀取需求,一個Linux部署目標,一個網路API,一個Docker容器,一個雲函式——C1BarCode無法應對。 IronBarcode涵蓋生成和讀取,運行於.NET支持的任何平台,並作為獨立包提供,無需訂閱100控件的企業套件。

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。