@@ -67,6 +67,7 @@ private static IntPtr DllImportResolver(
6767 string rid = OperatingSystem . IsWindows ( ) ? "win-x64" : "linux-x64" ;
6868 string runtimePath = Path . Join (
6969 assemblyDirectory , "runtimes" , rid , "native" , platformLibraryName ) ;
70+ List < string > searchedPaths = [ runtimePath ] ;
7071
7172 if ( File . Exists ( runtimePath ) )
7273 {
@@ -75,6 +76,7 @@ private static IntPtr DllImportResolver(
7576
7677 // Check assembly directory directly (local development)
7778 string localPath = Path . Join ( assemblyDirectory , platformLibraryName ) ;
79+ searchedPaths . Add ( localPath ) ;
7880 if ( File . Exists ( localPath ) )
7981 {
8082 return NativeLibrary . Load ( localPath ) ;
@@ -87,12 +89,14 @@ private static IntPtr DllImportResolver(
8789 while ( dir != null )
8890 {
8991 string cargoTarget = Path . Join ( dir , "target" , "debug" , platformLibraryName ) ;
92+ searchedPaths . Add ( cargoTarget ) ;
9093 if ( File . Exists ( cargoTarget ) )
9194 {
9295 return NativeLibrary . Load ( cargoTarget ) ;
9396 }
9497
9598 string cargoTargetRelease = Path . Join ( dir , "target" , "release" , platformLibraryName ) ;
99+ searchedPaths . Add ( cargoTargetRelease ) ;
96100 if ( File . Exists ( cargoTargetRelease ) )
97101 {
98102 return NativeLibrary . Load ( cargoTargetRelease ) ;
@@ -102,8 +106,9 @@ private static IntPtr DllImportResolver(
102106 }
103107#endif
104108
105- // Fallback to default resolution
106- return IntPtr . Zero ;
109+ throw new DllNotFoundException (
110+ $ "Unable to load native library '{ libraryName } '. Searched paths: " +
111+ string . Join ( Path . PathSeparator , searchedPaths ) ) ;
107112 }
108113
109114 // -----------------------------------------------------------------------
0 commit comments