Skip to content

Commit 5b9d360

Browse files
committed
refine
1 parent b126c2d commit 5b9d360

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -903,18 +903,14 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
903903
{
904904
if (libraryName == NativeLib.DllName)
905905
{
906-
// Map to platform-specific library name
907-
string mappedName = libraryName;
908-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
906+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
909907
{
910-
mappedName = "libonnxruntime.so";
911-
}
912-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
913-
{
914-
mappedName = "libonnxruntime.dylib";
908+
return IntPtr.Zero;
915909
}
916910

917-
if (NativeLibrary.TryLoad(mappedName, assembly, searchPath, out IntPtr handle))
911+
// On Linux/macOS, .NET's NativeLibrary.TryLoad works best with the simple library name
912+
// to find assets in the runtimes folder of a NuGet package.
913+
if (NativeLibrary.TryLoad("onnxruntime", assembly, searchPath, out IntPtr handle))
918914
{
919915
return handle;
920916
}

0 commit comments

Comments
 (0)