IronBarcode 故障排除 未識別 MSI 條碼 IronBarcode無法辨識 MSI 條碼 Curtis Chau 更新:2025年8月19日 下載 IronBarcode NuGet 下載 DLL 下載 開始免費試用 LLM副本 LLM副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 問題 使用IronBarcode庫建立 MSI 條碼時,有時會出現 BarcodeReader.Read 方法無法讀取產生的 MSI 條碼的情況,導致掃描結果為空,且條碼傳回預期值。 解決方案 為了確保 BarcodeReader.Read 能夠讀取 MSI 條碼,我們必須為 Read 方法提供輔助可選參數 BarcodeReaderOptions。 在 BarcodeReaderOptions 中,我們透過賦值 ExpectedBarcodeTypes 來明確指定我們要讀取的條碼類型。 這樣,Read 方法就可以辨識IronBarcode產生的 MSI 條碼以及任何外部 MSI 條碼。 下面是一個如何將 BarcodeReaderOptions 應用於 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 } // 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 } $vbLabelText $csharpLabel 在這個範例中,我們首先實例化一個新的 BarcodeReaderOptions 變量,然後將 ExpectedBarcodeTypes 賦值給 BarcodeEncoding.MSI 枚舉,指示IronBarcode期望的是 MSI 條碼。 之後,我們在 for 迴圈中列印出條碼的值,即 12345,因為 barcodeResults 傳回一個 BarcodeResults 數組,並遍歷每個結果以取得文字值。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 2,121,847 | 版本: 2026.3 剛剛發布 開始免費試用 免費 NuGet 下載 總下載量:2,121,847 查看許可證 還在捲動嗎? 想要快速證明? PM > Install-Package BarCode 執行範例 看您的字串變成 BarCode。 免費 NuGet 下載 總下載量:2,121,847 查看許可證