Fehlende DLLs bei der Erstellung eines MSI-Installers
Bei der Erstellung eines MSI-Installers kann die folgende Ausnahme auftreten:
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)
Grund
Dieser Fehler tritt auf, weil die Bibliothek die erforderlichen Dateien nicht finden kann, um ordnungsgemäß zu funktionieren.
Lösung
Damit der MSI-Installer reibungslos läuft, müssen Sie die folgenden drei Dateien in Ihr Setup-Projekt einschließen: onnxruntime.dll, IronBarcodeInterop.dll und ReaderInterop.dll. Diese Dateien werden generiert, wenn Sie das Projekt im Release-Modus aufbauen:
onnxruntime.dll: Befindet sich unter MsiInstallerSample\MsiInstallerSample\bin\ReleaseIronBarcodeInterop.dll: Befindet sich unter MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\nativeReaderInterop.dll: Befindet sich unter MsiInstallerSample\MsiInstallerSample\bin\Release\runtimes\win-x86\native
Stellen Sie sicher, dass alle drei Dateien zu Ihrem Setup-Projekt hinzugefügt werden, um diese Ausnahme zu vermeiden.
Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender Handbücher.