public IntPtr LoadUnmanagedLibrary(string name) { if (_unloadableNativeLibs.Contains(name)) { return(IntPtr.Zero); } foreach (var projectPath in _projects.Values.Select(p => p.Project.ProjectDirectory)) { foreach (var folder in NativeLibPathUtils.GetNativeSubfolderCandidates(RuntimeEnvironmentHelper.RuntimeEnvironment)) { var path = NativeLibPathUtils.GetProjectNativeLibPath(projectPath, folder); if (Directory.Exists(path)) { var handle = LoadUnamangedLibrary(path, name); if (handle != IntPtr.Zero) { return(handle); } } } } _unloadableNativeLibs.Add(name); return(IntPtr.Zero); }
public void GetNativeSubfolderCandidatesRetunsExpectedFolders(string os, string version, string architecture, string[] expected) { if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DNX_RUNTIME_ID"))) { return; } var runtimeEnvironment = new FakeRuntimeEnvironment { OperatingSystem = os, OperatingSystemVersion = version, RuntimeArchitecture = architecture }; var actual = NativeLibPathUtils.GetNativeSubfolderCandidates(runtimeEnvironment); Assert.Equal(expected, actual); }