예제 #1
0
        IntPtr INativeLibraryLoader.LoadLibrary(string path)
        {
            Trace.WriteLine("Opening a library: " + path);
            try
            {
                int flags  = GetDLOpenFlags();
                var result = UnixLibraryLoader.dlopen(path, flags);
                Trace.WriteLine("Open result: " + result);
                if (result == IntPtr.Zero)
                {
                    var lastError = dlerror();
                    Trace.WriteLine($"Failed to load native library \"{path}\".\r\nLast Error:{lastError}\r\nCheck inner exception and\\or windows event log.");
                }
                return(result);
            }
            catch (Exception ex)
            {
                var lastError = dlerror();
                Trace.WriteLine($"Failed to load native library \"{path}\".\r\nLast Error:{lastError}\r\nCheck inner exception and\\or windows event log.\r\nInner Exception: {ex.ToString()}");

                Trace.WriteLine(ex.ToString());
                return(IntPtr.Zero);
            }
        }
예제 #2
0
 IntPtr INativeLibraryLoader.FindFunction(IntPtr library, string function)
 {
     return(UnixLibraryLoader.dlsym(library, function));
 }
예제 #3
0
 bool INativeLibraryLoader.UnloadLibrary(IntPtr library)
 {
     return(UnixLibraryLoader.dlclose(library) == 0);
 }
예제 #4
0
 public IntPtr LastError()
 {
     return(UnixLibraryLoader.dlerror());
 }