public static IntPtr OnnxRuntimeImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) { //调试信息 LogHelper.NlogTrace(libraryName); if (libraryName != "onnxruntime") { return IntPtr.Zero; } var fullLoc = Assembly.Load("Microsoft.ML.OnnxRuntime").Location; //var loc = fullLoc.Substring(0, fullLoc.IndexOf("Microsoft.ML.OnnxRuntime")); var loc = "C:\\Windows\\SysWOW64\\onnxruntime.dll"; IntPtr libHandle = IntPtr.Zero; var ret = NativeLibrary.TryLoad(loc, out libHandle); //调试信息 LogHelper.NlogTrace(loc); LogHelper.NlogTrace(libHandle.ToString()); LogHelper.NlogTrace(ret.ToString()); return libHandle; } NativeLibrary.SetDllImportResolver(Assembly.Load("Microsoft.ML.OnnxRuntime"), Library.OnnxRuntimeImportResolver);
标签:loc,LogHelper,IntPtr,onnxruntime,var,NlogTrace,动态,加载 From: https://www.cnblogs.com/woox/p/17957963