@@ -932,21 +932,30 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
932932 // Probe the specific RID first, then common fallbacks for the current OS
933933 string [ ] ridsToTry ;
934934 if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
935+ {
935936 ridsToTry = new [ ] { rid , "win-x64" , "win-arm64" } ;
937+ }
936938 else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
939+ {
937940 ridsToTry = new [ ] { rid , "linux-x64" , "linux-arm64" } ;
941+ }
938942 else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
943+ {
939944 // We no longer provide osx-x64 in official package since 1.24.
940945 // However, we keep it in the list for build-from-source users.
941946 ridsToTry = new [ ] { rid , "osx-arm64" , "osx-x64" } ;
947+ }
942948 else
949+ {
943950 ridsToTry = new [ ] { rid } ;
951+ }
944952
945953 foreach ( var tryRid in ridsToTry )
946954 {
947955 string probePath = System . IO . Path . Combine ( assemblyDir , "runtimes" , tryRid , "native" , mappedName ) ;
948956 if ( System . IO . File . Exists ( probePath ) && NativeLibrary . TryLoad ( probePath , assembly , searchPath , out handle ) )
949957 {
958+ LogLibLoad ( $ "[DllImportResolver] Loaded { mappedName } from: { probePath } ") ;
950959 return handle ;
951960 }
952961 }
@@ -959,26 +968,36 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
959968 string probePath = System . IO . Path . Combine ( baseDir , mappedName ) ;
960969 if ( NativeLibrary . TryLoad ( probePath , assembly , searchPath , out handle ) )
961970 {
971+ LogLibLoad ( $ "[DllImportResolver] Loaded { mappedName } from: { probePath } ") ;
962972 return handle ;
963973 }
964974
965975 string rid = RuntimeInformation . RuntimeIdentifier ;
966976 probePath = System . IO . Path . Combine ( baseDir , "runtimes" , rid , "native" , mappedName ) ;
967977 if ( NativeLibrary . TryLoad ( probePath , assembly , searchPath , out handle ) )
968978 {
979+ LogLibLoad ( $ "[DllImportResolver] Loaded { mappedName } from: { probePath } ") ;
969980 return handle ;
970981 }
971982 }
972983
973- #if DEBUG
974- System . Console . WriteLine ( $ "[DllImportResolver] Failed loading { mappedName } (RID: { RuntimeInformation . RuntimeIdentifier } , Assembly: { assemblyLocation } )") ;
975- #endif
984+ LogLibLoad ( $ "[DllImportResolver] Failed loading { mappedName } (RID: { RuntimeInformation . RuntimeIdentifier } , Assembly: { assemblyLocation } )") ;
985+
976986 }
977987 }
978988
979989 // Fall back to default resolution
980990 return IntPtr . Zero ;
981991 }
992+
993+ private static void LogLibLoad ( string message )
994+ {
995+ System . Diagnostics . Trace . WriteLine ( message ) ;
996+ if ( ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "ORT_LOADER_VERBOSITY" ) ) )
997+ {
998+ Console . WriteLine ( message ) ;
999+ }
1000+ }
9821001#endif
9831002
9841003 [ DllImport ( NativeLib . DllName , CharSet = CharSet . Ansi ) ]
0 commit comments