- Copy DLLs: Ensure
onnxruntime.dll
is copied to your WPF app’s output directory. - Set DLL Path: Add this code at the start of your app to set the DLL search path:
using System;
using System.IO;
using System.Runtime.InteropServices;
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "path_to_your_dlls");
SetDllDirectory(path);
- Deploy Properly: Ensure all necessary DLLs are included in your deployment package.
This should help your app reference the correct onnxruntime.dll
.