创建 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 刚刚发布






