MSIインストーラーの作成時にDLLが不足しています
Curtis Chau
更新日: 2025年9月24日
MSIインストーラーを作成する際、次の例外が発生することがあります:
2025-01-27 16:57:23 - Error: IronBarCodeDetection.Exceptions.IronBarcodeDetectionException: Unexpected error occurred during execution of the IronBarcode Machine Learning library. Please provide details to support@ironsoftware.com for a resolution. ---> System.TypeInitializationException: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.ML.OnnxRuntime.NativeMethods..cctor()
--- End of inner exception stack trace ---
at Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
at Iron.BarCode.Extensions.xjtagg`1..ctor(Stream dfepdx, SessionOptions dfepdy)
at IronBarCodeDetection.BarcodeDetect.PredictObject[TModel](Stream modelStream)
--- End of inner exception stack trace ---
at IronBarCodeDetection.BarcodeDetect.PredictObject[TModel](Stream modelStream)
at IronBarCodeDetection.BarcodeDetect.DetectBarCode()
at Iron.BarCode.Extensions.cuewjf.ehxbbs(BarcodeDetect tlxjvd)
at Iron.BarCode.Extensions.cuewjf.ehxbbr(AnyBitmap tlxjvd, Double tlxjve)
at Iron.BarCode.Extensions.cuewjo.mvanli(AnyBitmap tlxjvd, Double tlxjve)
at Iron.BarCode.Extensions.cuewjo.mvanlf(Image`1 tlxjvd)
at Iron.BarCode.Extensions.cuewjo.mvankh(Object tlxjvd)
at IronBarCode.BarcodeReader.Read(AnyBitmap inputImage, BarcodeReaderOptions barcodeReaderOptions)
at WindowsFormsBarcode.Form1.btnBrowse_Click_1(Object sender, EventArgs e)
2025-01-27 16:57:23 - Error Message: Unexpected error occurred during execution of the IronBarcode Machine Learning library. Please provide details to support@ironsoftware.com for a resolution.
2025-01-27 16:57:23 - Inner Exception: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.
2025-01-27 16:57:23 - Inner Exception Stack Trace: at Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
at Iron.BarCode.Extensions.xjtagg`1..ctor(Stream dfepdx, SessionOptions dfepdy)
at IronBarCodeDetection.BarcodeDetect.PredictObject[TModel](Stream modelStream)
Text
理由
このエラーは、ライブラリが正常に機能するために必要なファイルを見つけられないために発生します。
解決策
MSIインストーラーがスムーズに実行されるようにするために、セットアッププロジェクトに次の3つのファイルを含める必要があります:onnxruntime.dll、IronBarcodeInterop.dll、そしてReaderInterop.dll。 これらのファイルは、Releaseモードでプロジェクトをビルドすると生成されます:
onnxruntime.dll: MsiInstallerSample\MsiInstallerSample\bin\Release にありますIronBarcodeInterop.dll: MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native にありますReaderInterop.dll: MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native にあります
この例外を避けるために、すべての3つのファイルをセットアッププロジェクトに追加することを確認してください。
テクニカルライター
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。