Provides methods to load libraries from standard .NET search locations. This class is not used to load native libraries for JNI. On platforms that have native NativeLibrary support, that support is used. On other platforms, libikvm is used to invoke the platform loader.
More...
|
| static string | MapLibraryName (string name) |
| | Returns a version of the library name with the OS specific prefix and suffix.
|
| |
| static NativeLibraryHandle | Load (string nameOrPath) |
| | Loads the given library in a platform dependent manner.
|
| |
Provides methods to load libraries from standard .NET search locations. This class is not used to load native libraries for JNI. On platforms that have native NativeLibrary support, that support is used. On other platforms, libikvm is used to invoke the platform loader.
Definition at line 15 of file NativeLibrary.cs.
◆ Load()
| static NativeLibraryHandle IKVM.Runtime.NativeLibrary.Load |
( |
string | nameOrPath | ) |
|
|
static |
Loads the given library in a platform dependent manner.
- Parameters
-
- Returns
Definition at line 66 of file NativeLibrary.cs.
67 {
68 if (Path.IsPathRooted(nameOrPath))
69 return LoadImpl(nameOrPath);
70
71
72 if (LoadImpl(nameOrPath) is NativeLibraryHandle h1)
73 return h1;
74
75
76 var asml = typeof(NativeLibrary).Assembly.Location is string s && !string.IsNullOrEmpty(s) ? Path.GetDirectoryName(s) : null;
77 var root = Environment.GetEnvironmentVariable("IKVM_LIBRARY_PATH") ?? asml;
78
79
80 if (string.IsNullOrEmpty(root))
81 return null;
82
83
85 if (File.Exists(lib1) && LoadImpl(lib1) is NativeLibraryHandle h2)
86 return h2;
87
88
89 foreach (var rid in RuntimeUtil.SupportedRuntimeIdentifiers)
90 if (Path.Combine(root,
"runtimes", rid,
"native",
MapLibraryName(nameOrPath)) is
string lib2)
91 if (File.Exists(lib2) && LoadImpl(lib2) is NativeLibraryHandle h3)
92 return h3;
93
94 return null;
95 }
static string MapLibraryName(string name)
Returns a version of the library name with the OS specific prefix and suffix.
◆ MapLibraryName()
| static string IKVM.Runtime.NativeLibrary.MapLibraryName |
( |
string | name | ) |
|
|
static |
Returns a version of the library name with the OS specific prefix and suffix.
- Parameters
-
- Returns
Definition at line 29 of file NativeLibrary.cs.
30 {
31 if (name == null)
32 return null;
33 if (Path.HasExtension(name))
34 return name;
35
36 if (RuntimeUtil.IsWindows)
37 return name + ".dll";
38 else if (RuntimeUtil.IsOSX)
39 return "lib" + name + ".dylib";
40 else
41 return "lib" + name + ".so";
42 }
The documentation for this class was generated from the following file: