IronBarcode 故障排除 MSI 条形码未识别 IronBarCode Could Not Recognize MSI Barcode Curtis Chau 已更新:八月 19, 2025 Download IronBarcode NuGet 下载 DLL 下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Problem When creating an MSI barcode using the IronBarCode library, there are instances where the BarcodeReader.Read method is unable to read the generated MSI barcode, resulting in an empty scan and the expected value from the barcode. Solution To ensure that the BarcodeReader.Read can read the MSI barcode, we must provide the secondary optional BarcodeReaderOptions parameter for the Read method. Within the BarcodeReaderOptions, we explicitly specify the barcode type that we are trying to read by assigning the value ExpectedBarcodeTypes. This way, the Read method would recognize the MSI barcode generated from IronBarCode as well as any external MSI barcodes. Below is a quick example of how to apply BarcodeReaderOptions to BarcodeReader.Read. Code Example // 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 } // 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 } ' Creating MSI Barcode with the value "12345" Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.MSI) ' Save barcode as image myBarcode.SaveAsImage("msi.png") ' Reading MSI Dim barcodeReaderOptions As New BarcodeReaderOptions With {.ExpectBarcodeTypes = BarcodeEncoding.MSI} ' Read barcode with additional barcodeReaderOptions from above Dim barcodeResults = BarcodeReader.Read("msi.png", barcodeReaderOptions) ' Using a for loop and print out the result For Each result As BarcodeResult In barcodeResults Console.WriteLine(result.Text) ' Output: 12345 Next result $vbLabelText $csharpLabel In the example, we first instantiate a new BarcodeReaderOptions variable and then assign ExpectedBarcodeTypes with the BarcodeEncoding.MSI enum, instructing IronBarcode to expect the MSI barcode instead. Afterwards, we print out the value of the barcode, which would be 12345, in a for loop as the barcodeResults returns an array of BarcodeResults and loop through each result for the text value. Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? Nuget 下载 1,935,276 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:1,935,276 查看许可证