public static bool FreeLibrary(IntPtr library) { if (IsWindows) { return(Windows.FreeLibrary(library)); } return((IsOSX ? OSX.dlclose(library) : Linux.dlclose(library)) == 0); }
public void Close() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { if (this.handle != IntPtr.Zero) { Windows.FreeLibrary(this.handle); this.handle = IntPtr.Zero; } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { if (InteropRuntimeConfig.IsRunningOnMono) { if (this.handle != IntPtr.Zero) { Mono.dlclose(this.handle); this.handle = IntPtr.Zero; } } else if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Core")) { if (this.handle != IntPtr.Zero) { CoreCLR.dlclose(this.handle); this.handle = IntPtr.Zero; } } else { if (this.handle != IntPtr.Zero) { Linux.dlclose(this.handle); this.handle = IntPtr.Zero; } } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { if (this.handle != IntPtr.Zero) { MacOSX.dlclose(this.handle); this.handle = IntPtr.Zero; } } else { throw new InvalidOperationException("Unsupported platform."); } bLibOpen = false; }
private static bool PlatformSpecificFreeLibrary(IntPtr libraryAddr) { if (Platform.IsWindows) { return(Windows.FreeLibrary(libraryAddr)); } if (Platform.IsLinux) { if (Platform.IsMono) { return(Mono.dlclose(libraryAddr) != 0); } if (Platform.IsNetCore) { return(CoreClr.dlclose(libraryAddr) != 0); } return(Linux.dlclose(libraryAddr) != 0); } if (Platform.IsMacOSX) { return(MacOsx.dlclose(libraryAddr) != 0); } throw new InvalidOperationException("Unsupported platform."); }