Example #1
0
        /// <summary>
        /// Initializes static members of the <see cref="NativeLogging"/> class.
        /// </summary>
        static NativeLogging()
        {
            LoggerLibrary = NativeLibrary.Load(LoggerLibraryName, typeof(NativeLogging).Assembly, null);
            LogMessage    = NativeLibrary.GetExport(LoggerLibrary, "LogMessage");
            LogError      = NativeLibrary.GetExport(LoggerLibrary, "LogError");
            LogCallback   = NativeLibrary.GetExport(LoggerLibrary, "logCallback");

#if !NETSTANDARD2_0
            var vncServer = NativeMethods.ResolveDll(ServerLibraryName, typeof(LibVncServer).Assembly, null);
#else
            var vncServer = NativeLibrary.Load(ServerLibraryName, typeof(LibVncServer).Assembly, null);
#endif
            RfbLog = NativeLibrary.GetExport(vncServer, "rfbLog");
            RfbErr = NativeLibrary.GetExport(vncServer, "rfbErr");

            if (RfbLog != IntPtr.Zero)
            {
                Marshal.WriteIntPtr(RfbLog, NativeLogging.LogMessage);
            }

            if (RfbErr != IntPtr.Zero)
            {
                Marshal.WriteIntPtr(RfbErr, NativeLogging.LogError);
            }

            LogCallbackDelegate = new LogCallbackDelegateDefinition(RfbLogCallback);
            LogCallbackPtr      = Marshal.GetFunctionPointerForDelegate(LogCallbackDelegate);
            Marshal.WriteIntPtr(NativeLogging.LogCallback, LogCallbackPtr);
        }
Example #2
0
        /// <summary>
        /// Initializes static members of the <see cref="NativeLogging"/> class.
        /// </summary>
        static NativeLogging()
        {
            LoggerLibrary = NativeLibraryLoader.ResolveDll(LoggerLibraryName, typeof(NativeLogging).Assembly, null);

            if (LoggerLibrary == IntPtr.Zero)
            {
                throw new DllNotFoundException($"Could not load {LoggerLibraryName}");
            }

            LogMessage  = NativeLibrary.GetExport(LoggerLibrary, "LogMessage");
            LogError    = NativeLibrary.GetExport(LoggerLibrary, "LogError");
            LogCallback = NativeLibrary.GetExport(LoggerLibrary, "logCallback");

            var vncServer = NativeLibraryLoader.ResolveDll(ServerLibraryName, typeof(LibVncServer).Assembly, null);

            if (vncServer == IntPtr.Zero)
            {
                throw new DllNotFoundException($"Could not load {ServerLibraryName}");
            }

            RfbLog = NativeLibrary.GetExport(vncServer, "rfbLog");
            RfbErr = NativeLibrary.GetExport(vncServer, "rfbErr");

            if (RfbLog != IntPtr.Zero)
            {
                Marshal.WriteIntPtr(RfbLog, NativeLogging.LogMessage);
            }

            if (RfbErr != IntPtr.Zero)
            {
                Marshal.WriteIntPtr(RfbErr, NativeLogging.LogError);
            }

            LogCallbackDelegate = new LogCallbackDelegateDefinition(RfbLogCallback);
            LogCallbackPtr      = Marshal.GetFunctionPointerForDelegate(LogCallbackDelegate);
            Marshal.WriteIntPtr(NativeLogging.LogCallback, LogCallbackPtr);
        }