public LibraryLoader()
        {
#if NETSTANDARD1_5
            var is64Bit = IntPtr.Size == 8;
#else
            var is64Bit = Environment.Is64BitProcess;
#endif
            if (!is64Bit)
            {
                throw new PlatformNotSupportedException(
                          $"{this.GetType().Namespace} needs to be run in a 64-bit process.");
            }

            // Windows:
            // https://stackoverflow.com/questions/2864673/specify-the-search-path-for-dllimport-in-net
            //
            // See for better ways
            // https://github.com/dotnet/coreclr/issues/930
            // https://github.com/dotnet/corefx/issues/32015
            List <string> candidatePaths = new List <string>();

            // In the nuget package, get the shared library from a relative path of this assembly
            // Also, when running locally, get the shared library from a relative path of this assembly
            var    assembly = typeof(LibraryLoader).GetTypeInfo().Assembly;
            var    location = assembly.Location;
            string basepath = Path.GetDirectoryName(location);
            candidatePaths.Add(basepath);

            switch (OperatingSystemHelper.CurrentOperatingSystem)
            {
            case OperatingSystemPlatform.MacOS:
            {
                string[] suffixPaths = new[]
                {
                    "../../runtimes/osx/native/",
                    "runtimes/osx/native/",
                    string.Empty
                };
                string path = FindLibrary(candidatePaths, suffixPaths, "libmongocrypt.dylib");
                _loader = new DarwinLibraryLoader(path);
            }
            break;

            case OperatingSystemPlatform.Linux:
            {
                string[] suffixPaths = new[]
                {
                    "../../runtimes/linux/native/",
                    "runtimes/linux/native/",
                    string.Empty
                };
                string path = FindLibrary(candidatePaths, suffixPaths, "libmongocrypt.so");
                _loader = new LinuxLibrary(path);
            }
            break;

            case OperatingSystemPlatform.Windows:
            {
                string[] suffixPaths = new[]
                {
                    @"..\..\runtimes\win\native\",
                    @".\runtimes\win\native\",
                    string.Empty
                };
                string path = FindLibrary(candidatePaths, suffixPaths, "mongocrypt.dll");
                _loader = new WindowsLibrary(path);
            }
            break;

            default:
                // should not be reached. If we're here, then there is a bug in OperatingSystemHelper
                throw new PlatformNotSupportedException("Unsupported operating system.");
            }
        }
        public LibraryLoader()
        {
#if NET452 || NETSTANDARD2_0
            var is64Bit = Environment.Is64BitProcess;
#else
            var is64Bit = IntPtr.Size == 8;
#endif
            if (!is64Bit)
            {
                throw new PlatformNotSupportedException(
                          $"{this.GetType().Namespace} needs to be run in a 64-bit process.");
            }

            // Windows:
            // https://stackoverflow.com/questions/2864673/specify-the-search-path-for-dllimport-in-net
            //
            // See for better ways
            // https://github.com/dotnet/coreclr/issues/930
            // https://github.com/dotnet/corefx/issues/32015
            List <string> candidatePaths = new List <string>();

            // In the nuget package, get the shared library from a relative path of this assembly
            // Also, when running locally, get the shared library from a relative path of this assembly
            var    assembly = typeof(LibraryLoader).GetTypeInfo().Assembly;
            var    location = assembly.Location;
            string basepath = Path.GetDirectoryName(location);
            candidatePaths.Add(basepath);
            // TODO - .NET Standard 2.0
//            Trace.WriteLine("Base Path: " + basepath)

#if NETSTANDARD1_5
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                string[] suffixPaths = new[]
                {
                    "../../native/osx/",
                    string.Empty
                };
                string path = FindLibrary(candidatePaths, suffixPaths, "libmongocrypt.dylib");
                _loader = new DarwinLibraryLoader(path);
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                string[] suffixPaths = new[]
                {
                    "../../native/linux/",
                    string.Empty
                };
                string path = FindLibrary(candidatePaths, suffixPaths, "libmongocrypt.so");
                _loader = new LinuxLibrary(path);
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
#endif
            {
                string[] suffixPaths = new[]
                {
                    @"..\..\x64\native\windows\",
                    string.Empty
                };
                string path = FindLibrary(candidatePaths, suffixPaths, "mongocrypt.dll");
                _loader = new WindowsLibrary(path);
            }
        }