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); }
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); }
public static extern void install_gchandle_deleter(FreeGCHandleCallback callback);