DevExpress Barcode 与 IronBarcode:C# 条形码库对比
MESCIUS ComponentOne C1条形码 vs 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,那么本文将介绍该范围在实践中意味着什么。
了解 C1 条形码
C1BarCode是一个可视化控件。 生成工作流创建一个实例,设置属性,并调用 GetImage() 来检索 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);
// 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
WinForms 开发人员对属性设置器 API 并不陌生——它直接映射到设计器界面。 ShowText 和 CaptionPosition 都是设计器可见的属性,它们在代码中以相同方式工作。
C1BarCode支持38个符号体系,涵盖主流的1D和2D格式:Code 39, Code 128, EAN-8, EAN-13, UPC-A, UPC-E, ITF, QR Code, PDF417, 和DataMatrix等。 对于条形码生成,它涵盖了常见用例。
无读取 API
这并非可以通过配置选项来弥补的缺陷。 不存在 C1BarCodeReader 类。 在 C1BarCode 上不存在 Decode() 方法。 ComponentOne 的条形码控件在设计上仅用于生成条形码。
如果您的应用程序需要扫描上传图像中的条形码、验证打印标签、处理带有嵌入式代码的文档,或者从 Web API 中的二维码提取数据——C1BarCode 都无法实现这些功能。 你需要一个单独的库来进行读取,这就引出了一个问题:既然独立的条形码库可以同时满足这两个操作,为什么还要为包含 100 多个控制功能的EnterpriseSuite中的一个仅用于生成条形码的组件付费呢?
对于设计用于打印输出的 WinForms 条形码控件来说,缺少读取 API 并不罕见。 当需求增加时,就会成为一个决策点——而条形码需求几乎总是会增加。
仅限 Windows 限制
C1BarCode的WinForms和WPF版本需要Windows特定的目标框架配置:
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
net8.0-windows 目标框架标识符和 UseWindowsForms 不是可选的偏好设置。 C1.Win.BarCode 依赖于 System.Windows.Forms 类型 — Graphics — 这些仅存在于 Windows 上。 移除 net8.0-windows 会导致构建失败。 ComponentOne确实提供针对跨平台TFM的Blazor和ASP.NET Core MVC版本的条形码控件,但WinForms和WPF包绑定在Windows上。
相比之下,IronBarcode 目标是 net8.0(或任何受支持的 TFM)没有平台限制:
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
这在几个实际场景中都很重要:
- Azure App Service on Linux:新 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项目,即使是用于测试生成逻辑。
如果你的应用程序是一个WinForms桌面工具,并且只会在Windows上运行,那么平台限制就不是问题。 一旦部署要求包含任何 Linux 或云环境,问题就会出现。
Suite捆绑
C1BarCode控件作为ComponentOne Studio Enterprise的一部分出售,其中包括WinForms, WPF, Blazor, 和ASP.NET的完整ComponentOne控件套件。 ComponentOne Studio Enterprise的定价为每开发者每年$1,299(订阅); 单平台版本(WinForms或WPF)为每开发者每年$799。
该Suite包含 100 多个组件:网格、图表、日程安排程序、输入控件、报表设计器、地图控件、仪表等等。 如果您正在构建一个数据密集型应用,并且需要很多这些控件,那么套件定价可能有意义。 如果您需要条形码生成并由于搜索中找到ComponentOne而来,那么您正主要是为了一个控件而购买企业UI套件。
NuGet 包为 WinForms 的 C1.Win.BarCode(其他平台为 C1.WinUI.BarCode 和 C1.Blazor.BarCode)并通过 ComponentOne Studio 订阅进行许可。 对于希望仅获得条形码功能而不需要完整套件的开发者,没有单独的仅供条形码的许可层。
IronBarcode的定价结构不同:它是一个独立的条形码库,永久许可起价为单个开发者$749(Lite),三个$1,499(Plus),十个$2,999(Professional),不限开发者$5,999。 没有网格控件,没有图表库,没有报表设计器——只有您正在寻找的条形码功能。
二维码定制
这两个库都支持生成二维码,并提供自定义选项。 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);
// 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 Using
IronBarcode流畅链:
//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");
//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 方法需要实例化一个 C1BarCode 对象并设置多个属性,然后再调用 GetImage()。IronBarcode的 QRCodeWriter 使用流畅链式结构——每个操作都会返回条形码对象,最后调用 .SaveAsPng()。 没有需要管理的实例。
IronBarcode还支持在二维码中嵌入徽标,而 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");
' 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}");
}
// 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);
// 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");
// 二维码生成 to byte array (for HTTP response)
byte[] qrBytes = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400)
.ToPngBinaryData();
// Code 128 generation to file
BarcodeWriter.CreateBarcode("SHIP-20240312-7834", BarcodeEncoding.Code128)
.SaveAsPng("shipping-label.png");
// 二维码生成 to byte array (for HTTP response)
byte[] qrBytes = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400)
.ToPngBinaryData();
Imports System
' Code 128 generation to file
BarcodeWriter.CreateBarcode("SHIP-20240312-7834", BarcodeEncoding.Code128) _
.SaveAsPng("shipping-label.png")
' 二维码生成 to byte array (for HTTP response)
Dim qrBytes As Byte() = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400) _
.ToPngBinaryData()
支持的平台:Windows、Linux、macOS、Docker、Azure(应用服务和函数)、AWS Lambda。 支持的.NET版本:.NET Framework 4.6.2+, .NET Core 3.1+, 和.NET 5/6/7/8。
功能对比
| 特征 | MESCIUS ComponentOne C1条形码 | IronBarcode |
|---|---|---|
| 条形码生成 | 是 | 是 |
| 条形码读取 | 否 | 是 |
| 二维码生成 | 是 | 是 |
| 二维码标志嵌入 | 否 | 是 |
| 用于阅读的 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包 | 套件许可证包 | 是 |
| 独立定价 | 不适用 | 永久版(Lite)起价 749 美元 |
| Suite定价 | $1,299/开发者/年 企业版;$799/开发者/年 单平台 | 不适用 |
| 流畅生成 API | 否(属性设置者) | 是 |
BarcodeReader.Read() |
否 | 是 |
BarcodeWriter.CreateBarcode() |
否 | 是 |
QRCodeWriter.CreateQrCode() |
否 | 是 |
| 支持的.NET版本 | .NET 6+(Windows用于WinForms/WPF) | .NET Framework 4.6.2+、.NET Core 3.1+、.NET 5-8 |
| 永久许可选项 | 无需订阅 | 是 |
API 映射参考
对于从 C1BarCode 迁移到IronBarcode 的团队,以下直接对应关系适用:
| ComponentOne C1条形码 | 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 构建条形码标签生成器,然后收到验证扫描、处理入库货运单据或解码上传图像中的二维码的需求。 C1BarCode 无法解决这个问题。有两种选择:要么添加第二个条形码读取库,要么用一个可以同时处理这两种情况的库替换 C1BarCode。
Linux 或 Docker 部署。而发布到 Windows 桌面的 WinForms 桌面应用程序则不受此限制。 生成条形码图像的ASP.NET Core API 确实如此——尤其是在需要在 Linux 容器中运行或部署到 Linux 上的 Azure 应用服务时。 net8.0-windows 目标框架立即阻止这些部署选项。
微服务或无服务器架构。Azure Functions、AWS Lambda 和容器化微服务都优先考虑 Linux。无法部署到 Linux 的条形码生成服务不能称之为可行的微服务。
Suite订阅成本与需求范围。已经付费使用 ComponentOne Studio Enterprise并已在使用其网格、图表和其他控件的团队,已经证明了订阅的合理性。 主要或完全为了生成条形码而订阅的团队,正在为 100 多个他们没有使用的控件付费。 每个开发人员的订阅费用会随着团队规模的扩大而增加。
永久授权优先。ComponentOne Studio 仅提供订阅服务。 没有永久授权选项。 对于希望拥有所交付软件的团队——特别是为合规性或长期维护原因——IronBarcode的永久许可(起价为$749 Lite)在结构上不同。
结论
C1BarCode 能够在 WinForms 环境中干净利落地生成条形码。 这正是它真正擅长的,对于只需要在 Windows 上生成标签的 WinForms 桌面应用程序来说,它是 ComponentOneSuite中的一个功能性选择。
范围仅限于此。 不支持读取,仅限 Windows 部署,无独立软件包,采用订阅许可。 当一个项目的需求超出了在 Windows 上生成 WinForms 的范围时——例如阅读需求、Linux 部署目标、Web API、Docker 容器、云函数——C1BarCode 就无法满足这些需求了。 IronBarcode涵盖生成和读取功能,可在.NET支持的任何平台上运行,并且可以作为独立软件包使用,无需订阅包含 100 个控件的EnterpriseSuite。
常见问题解答
GrapeCity条形码是什么?
GrapeCity Barcode 是一个 .NET 条形码库,用于在 C# 应用程序中生成和读取条形码。它是开发人员在为 .NET 项目选择条形码解决方案时评估的几个备选方案之一。
GrapeCity Barcode 和 IronBarcode 的主要区别是什么?
IronBarcode 使用静态、无状态的 API,无需实例管理,而 GrapeCity Barcode 通常需要在使用前创建和配置实例。IronBarcode 还提供原生 PDF 支持、自动格式检测以及跨所有环境的单密钥许可。
IronBarcode 的授权比 GrapeCity Barcode 更容易吗?
IronBarcode 使用单一许可证密钥,同时涵盖开发和生产部署。与将 SDK 密钥与运行时密钥分开的许可系统相比,这简化了 CI/CD 流水线和 Docker 配置。
IronBarcode 是否支持 GrapeCity 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 渲染库。每页的读取结果包括页码、条形码格式、数值和置信度评分。
IronBarcode 与 GrapeCity Barcode 相比,在批量处理方面有何不同?
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 安装程序或运行时文件。
与 GrapeCity 不同,我可以在购买前评估 IronBarcode 吗?
是的。IronBarcode 的试用模式会返回完整的解码条形码值——只有生成的输出图像才会带有水印。您可以在购买前,用自己的文档测试读取准确率。
GrapeCity Barcode 和 IronBarcode 的价格有什么区别?
IronBarcode 的永久单开发者许可证起价为 749 美元,涵盖开发和生产环境。定价详情和批量许可选项请访问 IronBarcode 许可页面。无需单独的运行时许可证。
从 GrapeCity Barcode 迁移到 IronBarcode 是否很简单?
从 GrapeCity Barcode 迁移到 IronBarcode 主要涉及将基于实例的 API 调用替换为 IronBarcode 的静态方法、移除许可相关的样板代码以及更新结果属性名称。大多数迁移工作都是减少代码,而不是增加代码。
IronBarcode 能生成带有 logo 的二维码吗?
是的。`QRCodeWriter.CreateQrCode().AddBrandLogo("logo.png")` 可以将品牌图片原生嵌入二维码中,并支持配置纠错功能。此外,它还支持通过 `ChangeBarCodeColor()` 函数创建彩色二维码。

