Esempio n. 1
0
        static Native()
        {
            _libraryFacade = Environment.Is64BitProcess
                ? new Native64BitLibraryFacade()
                : (INativeLibraryFacade) new Native32BitLibraryFacade();

            Exception archSpecificException;

            _libraryVersion = GetVersionInfo(_libraryFacade, out archSpecificException);

            if (archSpecificException != null)
            {
                Exception fallbackException;

                var fallbackLibrary = new FallbackLibraryFacade();
                _libraryVersion = GetVersionInfo(fallbackLibrary, out fallbackException);

                if (fallbackException != null)
                {
                    throw archSpecificException;
                }

                _libraryFacade = fallbackLibrary;
            }
        }
Esempio n. 2
0
        private static LightningVersionInfo GetVersionInfo(INativeLibraryFacade lib, out Exception exception)
        {
            exception = null;

            LightningVersionInfo versionInfo = null;

            try
            {
                versionInfo = LightningVersionInfo.Create(lib);
            }
            catch (DllNotFoundException dllNotFoundException)
            {
                exception = dllNotFoundException;
            }
            catch (BadImageFormatException badImageFormatException)
            {
                exception = badImageFormatException;
            }

            return(versionInfo);
        }
Esempio n. 3
0
        static Native()
        {
            _libraryFacade = Environment.Is64BitProcess
                ? new Native64BitLibraryFacade()
                : (INativeLibraryFacade) new Native32BitLibraryFacade();

            Exception archSpecificException;
            _libraryVersion = GetVersionInfo(_libraryFacade, out archSpecificException);

            if (archSpecificException != null)
            {
                Exception fallbackException;

                var fallbackLibrary = new FallbackLibraryFacade();
                _libraryVersion = GetVersionInfo(fallbackLibrary, out fallbackException);

                if (fallbackException != null)
                    throw archSpecificException;

                _libraryFacade = fallbackLibrary;
            }
        }