Ejemplo n.º 1
0
        public static unsafe void Initialize()
        {
            try
            {
                if (RuntimeInformation.FrameworkDescription.Contains(".NET Framework") &&
                    RuntimeInformation.OSDescription.Contains("Windows"))
                {
                    var assemblyLocationPI = typeof(Assembly).GetProperty("Location", BindingFlags.Public | BindingFlags.Instance);
                    if (assemblyLocationPI != null)
                    {
                        var assemblyLocation = Path.GetDirectoryName((string)assemblyLocationPI.GetValue(typeof(NativeCommon).GetTypeInfo().Assembly));
                        var architecture     = InteropConfig.Is64BitProcess ? "x64" : "x86";
                        var path             = Path.Combine(assemblyLocation, "lib", "win32", architecture) + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH");
                        Environment.SetEnvironmentVariable("PATH", path);
                    }
                }
            }
            catch
            {
                // HACK
                // RuntimeInformation seems to throw on Android. As we're only interested in windows, swallow the exception.
            }

#if DEBUG
            DebugLoggerCallback logger = DebugLogger;
            GCHandle.Alloc(logger);
            set_debug_logger(logger);
#endif

            FreeGCHandleCallback gchandleDeleter = FreeGCHandle;
            GCHandle.Alloc(gchandleDeleter);
            install_gchandle_deleter(gchandleDeleter);
        }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                var assemblyLocation = Path.GetDirectoryName(typeof(NativeCommon).Assembly.Location);
                var architecture     = Environment.Is64BitProcess ? "x64" : "x86";
                var path             = Path.Combine(assemblyLocation, "lib", "win32", architecture) + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH");
                Environment.SetEnvironmentVariable("PATH", path);
            }

#if DEBUG
            DebugLoggerCallback logger = DebugLogger;
            GCHandle.Alloc(logger);
            set_debug_logger(logger);
#endif

            FreeGCHandleCallback gchandleDeleter = FreeGCHandle;
            GCHandle.Alloc(gchandleDeleter);
            install_gchandle_deleter(gchandleDeleter);
        }
Ejemplo n.º 3
0
 public static extern void install_gchandle_deleter(FreeGCHandleCallback callback);