Beispiel #1
0
        static UnmanagedUtils()
        {
            var platform = Environment.Is64BitProcess ? "x64" : "x86";

            var resName = string.Format("{0}.{1}", platform, IgniteUtils.FileIgniteJniDll);

            var path = IgniteUtils.UnpackEmbeddedResource(resName, IgniteUtils.FileIgniteJniDll);

            var ptr = NativeMethods.LoadLibrary(path);

            if (ptr == IntPtr.Zero)
            {
                var err = Marshal.GetLastWin32Error();

                throw new IgniteException(string.Format("Failed to load {0} from {1}: [{2}]",
                                                        IgniteUtils.FileIgniteJniDll, path, IgniteUtils.FormatWin32Error(err)));
            }

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

            JNI.SetConsoleHandler(UnmanagedCallbacks.ConsoleWriteHandler);

            // Clean directories in background to avoid extra work on start.
            Task.Factory.StartNew(IgniteUtils.TryCleanTempDirectories);
        }