Esempio n. 1
0
        public static void LoadLibraryFromResources(string _libraryName)
        {
            var dllHandle = LoadLibrary(_libraryName);

            if (dllHandle != IntPtr.Zero)
            {
                return;
            }
            var dllBytes = ResourcesHelper.GetResourcesBytes(_libraryName);

            if (dllBytes == null)
            {
                throw new ApplicationException(string.Format("Could not extract library '{0}' from resources!", _libraryName));
            }
            var dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _libraryName);

            File.WriteAllBytes(dllPath, dllBytes);
            dllHandle = LoadLibrary(dllPath);
            if (dllHandle == IntPtr.Zero)
            {
                var error = new Win32Exception(Marshal.GetLastWin32Error()).Message;
                throw new ApplicationException(string.Format("Could not load library '{0}' ! Error: {1}", _libraryName, error));
            }
        }
Esempio n. 2
0
 public WinSparkle64()
 {
     ResourcesHelper.LoadLibraryFromResources(WinSparkleDllName);
 }