public SafeHandleUnmanagedDll(string dllName) : base(true) { IDynamicLibraryLoader libraryLoader = null; if (PlatformUtility.IsUnix) libraryLoader = new UnixLibraryLoader(); else if (Environment.OSVersion.Platform == PlatformID.Win32NT) libraryLoader = new WindowsLibraryLoader(); else throw new NotSupportedException(PlatformUtility.GetPlatformNotSupportedMsg()); this.libraryLoader = libraryLoader; handle = libraryLoader.LoadLibrary(dllName); }
static IntPtr LoadDll(IDynamicLibraryLoader loader, GtkDll dll) { var exceptions = new List <Exception>(); var name = GetDllName(dll); if (Custom?.TrySystemFirst != false) { try { return(loader.LoadLibrary(name)); } catch (Exception e) { exceptions.Add(e); } } var path = Custom?.Lookup(dll); if (path == null && Custom?.BasePath != null) { path = Path.Combine(Custom.BasePath, name); } if (path != null) { try { return(loader.LoadLibrary(path)); } catch (Exception e) { exceptions.Add(e); } } throw new AggregateException("Unable to load " + dll, exceptions); }
public static IntPtr LoadLibrary(string lib) { return(Loader.LoadLibrary(lib)); }