IRONSOFTWAREHOME

IronBarcode 无法识别 MSI 条码

Curtis Chau
Curtis Chau
Updated: 2025年8月20日

问题

使用IronBarcode库创建MSI条码时,某些情况下BarcodeReader.Read方法无法读取生成的MSI条码,导致扫描结果为空以及预期的条码值。

解决方案

为确保BarcodeReaderOptions参数。 在ExpectedBarcodeTypes。 这样,Read方法可以识别由IronBarcode生成的MSI条码以及任何外部的MSI条码。

下面是一个如何将BarcodeReader.Read的快速示例。

代码示例

// Creating MSI Barcode with the value "12345"
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI);

// Save barcode as image
myBarcode.SaveAsImage("msi.png");


// Reading MSI
var barcodeReaderOptions = new BarcodeReaderOptions
{
     // Assigning BarcodeEncoding.MSI to ExpectBarcodeType to ensure that IronBarcode expects MSI type barcodes specifically 
  ExpectBarcodeTypes = BarcodeEncoding.MSI,
};

// Read barcode with additional barcodeReaderOptions from above
var barcodeResults = BarcodeReader.Read("msi.png", barcodeReaderOptions);

// Using a for loop and print out the result 
foreach (BarcodeResult result in barcodeResults)
{
  Console.WriteLine(result.Text);
    // Output: 12345 
}

在示例中,我们首先实例化一个新的ExpectedBarcodeTypes赋值,指示IronBarcode预期为MSI条码。 之后,我们在for循环中打印出条码的值,即12345,因为BarcodeResults数组,并遍历每个结果获取文本值。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

...
阅读更多

准备开始了吗?

Nuget Downloads 2,422,100版本:2026.9刚刚发布

立即获取您的免费30 天试用密钥
无需信用卡或创建账户
C# 用于 PDF 的 NuGet 库
通过 NuGet 安装

版本: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. 在解决方案资源管理器中,右键点击引用,管理 NuGet 包
  2. 选择浏览并搜索 "IronBarcode"
  3. 选择包并安装
C# PDF DLL
下载 DLL

版本: 2026.9

  1. 下载并将 IronBarCode 解压到解决方案目录中的 ~/Libs 等位置
  2. 在 Visual Studio 解决方案资源管理器中,右键单击引用。选择浏览,"IronBarcode.dll"

许可 $999

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

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户