建立 MSI 安裝程式時缺少 DLL 文件
This article was translated from English: Does it need improvement?
TranslatedView the article in English
建立 MSI 安裝程式時,可能會遇到以下異常:
2025-01-27 16:57:23 - 錯誤:IronBarCodeDetection.Exceptions.IronBarcodeDetectionException:執行 IronBarcode 機器學習程式庫時發生意外錯誤。 請將詳細資訊發送至 support@ironsoftware.com 以便我們解決問題。 ---> System.TypeInitializationException: "Microsoft.ML.OnnxRuntime.NativeMethods"的型別初始值設定項引發了例外狀況。 ---> System.NullReferenceException: 物件引用未設定為物件的實例。
在 Microsoft.ML.OnnxRuntime.NativeMethods..cctor()
--- 內部異常堆疊追蹤結束 ---
在 Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
在 Iron.BarCode.Extensions.xjtagg`1..ctor(Stream dfepdx, SessionOptions dfepdy)
在 IronBarCodeDetection.BarcodeDetect.PredictObject [TModel](Stream modelStream)
--- 內部異常堆疊追蹤結束 ---
在 IronBarCodeDetection.BarcodeDetect.PredictObject [TModel](Stream modelStream)
在 IronBarCodeDetection.BarcodeDetect.DetectBarCode()
在 Iron.BarCode.Extensions.cuewjf.ehxbbs(BarcodeDetect tlxjvd)
在 Iron.BarCode.Extensions.cuewjf.ehxbbr(AnyBitmap tlxjvd, Double tlxjve)
在 Iron.BarCode.Extensions.cuewjo.mvanli(AnyBitmap tlxjvd, Double tlxjve)
在 Iron.BarCode.Extensions.cuewjo.mvanlf(Image`1 tlxjvd)
在 Iron.BarCode.Extensions.cuewjo.mvankh(Object tlxjvd)
在 IronBarCode.BarcodeReader.Read(AnyBitmap inputImage, BarcodeReaderOptions barcodeReaderOptions)
在 WindowsFormsBarcode.Form1.btnBrowse_Click_1(Object sender, EventArgs e)
2025-01-27 16:57:23 - 錯誤訊息:執行 IronBarcode 機器學習庫時發生意外錯誤。 請將詳細資訊發送至 support@ironsoftware.com 以便我們解決問題。
2025-01-27 16:57:23 - 內部異常:類型"Microsoft.ML.OnnxRuntime.NativeMethods"的型別初始值設定項引發了異常。
2025-01-27 16:57:23 - 內部異常堆疊追蹤:位於 Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
在 Iron.BarCode.Extensions.xjtagg`1..ctor(Stream dfepdx, SessionOptions dfepdy)
在 IronBarCodeDetection.BarcodeDetect.PredictObject [TModel](Stream modelStream)原因
出現此錯誤是因為程式庫找不到正常運作所需的檔案。
解決方案
為確保 MSI 安裝程式順利運行,您必須在安裝專案中包含以下三個檔案: onnxruntime.dll 、 IronBarcodeInterop.dll和ReaderInterop.dll 。 這些文件是在以發布模式建立專案時產生的:
onnxruntime.dll:位於 MsiInstallerSample\MsiInstallerSample\bin\ReleaseIronBarcodeInterop.dll:位於 MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\nativeReaderInterop.dll:位於 MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native
請確保將這三個檔案都新增到您的安裝專案中,以避免此異常。
準備好開始了嗎?
Nuget 下載 2,002,059 | 版本: 2025.12 剛發表






