當前位置: 首頁>>代碼示例>>C#>>正文


C# AssemblyInstaller.Rollback方法代碼示例

本文整理匯總了C#中System.Configuration.Install.AssemblyInstaller.Rollback方法的典型用法代碼示例。如果您正苦於以下問題:C# AssemblyInstaller.Rollback方法的具體用法?C# AssemblyInstaller.Rollback怎麽用?C# AssemblyInstaller.Rollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Configuration.Install.AssemblyInstaller的用法示例。


在下文中一共展示了AssemblyInstaller.Rollback方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InstallTheService

 public void InstallTheService()
 {
     try
     {
         IDictionary state = new Hashtable();
         using (AssemblyInstaller installer = new AssemblyInstaller(InstallersAssembly, Args))
         {
             installer.UseNewContext = true;
             try
             {
                 installer.Install(state);
                 installer.Commit(state);
                 InternalTrace("Installed the service");
             }
             catch (Exception installException)
             {
                 try
                 {
                     installer.Rollback(state);
                     InternalTrace("Rolledback the service installation because:" + installException.ToString());
                 }
                 catch { }
                 throw;
             }
         }
     }
     catch (Exception exception)
     {
         InternalTrace("Failed to install the service " + exception.ToString());
     }
 }
開發者ID:MecuSorin,項目名稱:Configurari,代碼行數:31,代碼來源:CommandLineManager.cs

示例2: Uninstall

        public static void Uninstall(string[] args)
        {
            try
            {
                using (var installer = new AssemblyInstaller(typeof(InstallationManager).Assembly, args))
                {
                    IDictionary state = new Hashtable();

                    // Install the service
                    installer.UseNewContext = true;
                    try
                    {
                        installer.Uninstall(state);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());

                        try
                        {
                            installer.Rollback(state);
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception.ToString());
                        }
                    }
                }
            }
            catch (Exception exception)
            {

                Console.WriteLine("Failed to install service. Error: " + exception.Message);
            }
        }
開發者ID:hagenson,項目名稱:SysLogSharp,代碼行數:35,代碼來源:InstallationManager.cs

示例3: InstallService

        public void InstallService(string user, string pass) {
            using (AssemblyInstaller installer = new AssemblyInstaller(Path.Combine(Utils.GetApplicationPath(), Utils.GetExecutableName()), null)) {
                installer.UseNewContext = true;
                Hashtable savedState = new Hashtable();

                UserPassCombination c = new UserPassCombination();
                c.User = user;
                c.Pass = pass;
                _userPassCombination = c;

                installer.BeforeInstall += new InstallEventHandler(installer_BeforeInstall);

                //Rollback has to be called by user code. According msdn-doc for AssemblyInstaller.Install() is probably wrong.
                try {
                    installer.Install(savedState);
                    installer.Commit(savedState);
                }
                catch (Exception ex) {
                    installer.Rollback(savedState);
                    throw new InstallException(String.Format("Install failed: {0}", ex.Message), ex);
                }

                installer.BeforeInstall -= installer_BeforeInstall;
            }
        }
開發者ID:shabbirh,項目名稱:virtualboxservice,代碼行數:25,代碼來源:ElevatedService.cs

示例4: TryRollback

        private void TryRollback(AssemblyInstaller installer, IDictionary state)
        {
            try { installer.Rollback(state); }
            catch (Exception ex )
            {
                _log.Write(LogLevel.Warning, "An error occured during rollback. {0}", ex);
            }

        }
開發者ID:vjohnson01,項目名稱:Tools,代碼行數:9,代碼來源:InstallUtil.cs

示例5: Install

        static void Install(bool undo, string[] args)
        {
            try
            {
                Console.WriteLine(undo ? "uninstalling" : "installing");
                using (AssemblyInstaller inst = new AssemblyInstaller(typeof(Program).Assembly, args))
                {
                    IDictionary state = new Hashtable();
                    inst.UseNewContext = true;
                    try
                    {
                        if (undo)
                        {
                            inst.Uninstall(state);
                        }
                        else
                        {
                            inst.Install(state);
                            inst.Commit(state);
                            try
                            {
                                ServiceController service = new ServiceController("DpFamService");
                                TimeSpan timeout = TimeSpan.FromMilliseconds(1000);

                                service.Start();
                                service.WaitForStatus(ServiceControllerStatus.Running, timeout);

                            }
                            catch
                            {
                                Console.WriteLine("Could not start the server\n");
                            }

                        }
                    }
                    catch
                    {
                        try
                        {
                            inst.Rollback(state);
                        }
                        catch { }
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
        }
開發者ID:akshaynm87,項目名稱:FamServer,代碼行數:51,代碼來源:Program.cs

示例6: Install

        public static bool Install()
        {
            Tracker.StartServer();

            bool result = true;

            InstallContext context = null;
            try
            {
                using (var inst = new AssemblyInstaller(typeof (ServerLifecycleManager).Assembly, null))
                {
                    context = inst.Context; 
                    LogMessage("Installing service " + AppSettings.ServiceName, inst.Context);
                    IDictionary state = new Hashtable();
                    inst.UseNewContext = true;

                    try
                    {
                        inst.Install(state);
                        inst.Commit(state);
                        Tracker.TrackEvent(TrackerEventGroup.Installations, TrackerEventName.Installed);
                    }
                    catch (Exception err)
                    {
                        Tracker.TrackException("WindowsServiceManager", "Install", err);
                        try
                        {
                            inst.Rollback(state);
                        }
                        catch (Exception innerErr)
                        {
                            throw new AggregateException(new List<Exception> {err, innerErr});
                        }
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
                WriteExceptions(ex, context);
            }
            finally
            {
                Tracker.Stop();
            }

            return result;
        }
開發者ID:Robin--,項目名稱:Warewolf,代碼行數:49,代碼來源:WindowsServiceManager.cs

示例7: Install

 // References http://stackoverflow.com/questions/1195478/how-to-make-a-net-windows-service-start-right-after-the-installation/1195621#1195621
 public static void Install()
 {
     using (AssemblyInstaller installer =
             new AssemblyInstaller(typeof(OpenVpnService).Assembly, null))
     {
         installer.UseNewContext = true;
         var state = new System.Collections.Hashtable();
         try
         {
             installer.Install(state);
             installer.Commit(state);
         } catch
         {
             installer.Rollback(state);
             throw;
         }
     }
 }
開發者ID:xkjyeah,項目名稱:openvpnserv2,代碼行數:19,代碼來源:ProjectInstaller.cs

示例8: Install

        static void Install(bool undo, string[] args)
        {
            try
            {
                Logger.Log(undo ? "Uninstalling ..." : "Installing ... ");
                using (var inst = new AssemblyInstaller(typeof(Program).Assembly, args))
                {
                    var state = new Hashtable();
                    inst.UseNewContext = true;
                    try
                    {
                        if (undo)
                        {
                            inst.Uninstall(state);
                        }
                        else
                        {
                            inst.Install(state);
                            inst.Commit(state);

                            StartService();
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            Logger.Log(ex);
                            inst.Rollback(state);
                        }
                        catch { }
                        throw;
                    }
                    inst.Dispose();
                }
                Logger.Log("... finished");
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
開發者ID:JuergenGutsch,項目名稱:async-proxy,代碼行數:42,代碼來源:Program.cs

示例9: Install

        public static bool Install(bool undo, string[] args)
        {
            try
            {
                Console.WriteLine(undo ? "Uninstalling..." : "Installing...");
                using (AssemblyInstaller inst = new AssemblyInstaller(typeof(WakeService).Assembly, args))
                {
                    IDictionary state = new Hashtable();
                    inst.UseNewContext = true;
                    try
                    {
                        if (undo)
                        {
                            inst.Uninstall(state);
                        }
                        else
                        {
                            inst.Install(state);
                            inst.Commit(state);
                        }
                    }
                    catch
                    {
                        try
                        {
                            inst.Rollback(state);
                        }
                        catch { }
                        throw;
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            return false;
        }
開發者ID:pleasereset,項目名稱:wakemypc-lighthouse,代碼行數:41,代碼來源:ProjectInstaller.cs

示例10: OnAction

        public void OnAction(Hashtable parameters)
        {
            ArrayList temp = new ArrayList();
            temp.Add("/LogToConsole=false");
            StringBuilder tempString = new StringBuilder();
            foreach (DictionaryEntry entry in parameters)
            {
                if (tempString.Length > 0)
                    tempString.Append(" ");
                tempString.Append(entry.Key);
                tempString.Append("=");
                tempString.Append(entry.Value);
            }
            temp.Add("commandline=" + tempString.ToString());

            string[] commandLine = (string[])temp.ToArray(typeof(string));

            System.Configuration.Install.AssemblyInstaller asmInstaller = new AssemblyInstaller(Assembly.GetExecutingAssembly(), commandLine);
            Hashtable rollback = new Hashtable();

            if (GameServerService.GetDOLService() != null)
            {
                Console.WriteLine("DOL service is already installed!");
                return;
            }

            Console.WriteLine("Installing Road as system service...");
            try
            {
                asmInstaller.Install(rollback);
                asmInstaller.Commit(rollback);
            }
            catch (Exception e)
            {
                asmInstaller.Rollback(rollback);
                Console.WriteLine("Error installing as system service");
                Console.WriteLine(e.Message);
                return;
            }
            Console.WriteLine("Finished!");
        }
開發者ID:geniushuai,項目名稱:DDTank-3.0,代碼行數:41,代碼來源:ServiceInstall.cs

示例11: Install

 public static bool Install(bool undo, string[] args)
 {
     try
     {
         using(var inst = new AssemblyInstaller(typeof(Program).Assembly, args))
         {
             inst.AfterInstall += OnAfterInstall;
             IDictionary state = new Hashtable();
             inst.UseNewContext = true;
             try
             {
                 if(undo)
                     inst.Uninstall(state);
                 else
                 {
                     inst.Install(state);
                     inst.Commit(state);
                 }
             }
             catch
             {
                 try
                 {
                     inst.Rollback(state);
                 }
                 catch
                 {
                     return false;
                 }
                 throw;
             }
         }
     }
     catch(Exception ex)
     {
         Console.WriteLine(ex);
         return false;
     }
     return true;
 }
開發者ID:huoxudong125,項目名稱:ServerX,代碼行數:40,代碼來源:WindowsServiceInstaller.cs

示例12: Install

 /// <summary>
 /// Actually installs/uninstalls this service.
 /// </summary>
 /// <param name="undo"></param>
 /// <param name="args"></param>
 private static void Install(bool undo, string[] args)
 {
     try
     {
         using (AssemblyInstaller installer = new AssemblyInstaller(
             Assembly.GetEntryAssembly(), args))
         {
             IDictionary savedState = new Hashtable();
             installer.UseNewContext = true;
             try
             {
                 if (undo)
                 {
                     installer.Uninstall(savedState);
                 }
                 else
                 {
                     installer.Install(savedState);
                     installer.Commit(savedState);
                 }
             }
             catch
             {
                 try
                 {
                     installer.Rollback(savedState);
                 }
                 catch
                 {
                 }
                 throw;
             }
         }
     }
     catch (Exception exception)
     {
         Console.Error.WriteLine(exception.Message);
     }
 }
開發者ID:jorik041,項目名稱:OsmSharpService,代碼行數:44,代碼來源:Program.cs

示例13: Install

 static void Install(bool undo, string[] args)
 {
     try
     {
         Console.WriteLine(undo ? "uninstalling" : "installing");
         using (AssemblyInstaller inst = new AssemblyInstaller(typeof(Program).Assembly, args))
         {
             IDictionary state = new Hashtable();
             inst.UseNewContext = true;
             try
             {
                 if (undo)
                 {
                     inst.Uninstall(state);
                 }
                 else
                 {
                     inst.Install(state);
                     inst.Commit(state);
                 }
             }
             catch
             {
                 try
                 {
                     inst.Rollback(state);
                 }
                 catch { }
                 throw;
             }
         }
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex.Message);
         throw;
     }
 }
開發者ID:prog76,項目名稱:SoftGetaway,代碼行數:38,代碼來源:Program.cs

示例14: InstallService

 private static void InstallService(bool undo, string[] args)
 {
     using (AssemblyInstaller inst = new AssemblyInstaller(Assembly.GetExecutingAssembly(), args)) {
         var state = new Hashtable();
         inst.UseNewContext = true;
         try {
             if (undo) {
                 inst.Uninstall(state);
             }
             else {
                 inst.Install(state);
                 inst.Commit(state);
             }
         }
         catch {
             try {
                 inst.Rollback(state);
             }
             catch { }
             throw;
         }
     }
 }
開發者ID:masroore,項目名稱:db4o-extras,代碼行數:23,代碼來源:Program.cs

示例15: Install

 public static void Install(bool undo, string openvpn)
 {
     try
     {
         using (AssemblyInstaller inst = new AssemblyInstaller(typeof(OpenVPNServiceRunner).Assembly, new String[0]))
         {
             IDictionary state = new Hashtable();
             inst.UseNewContext = true;
             try
             {
                 if (undo)
                 {
                     inst.Uninstall(state);
                 }
                 else
                 {
                     inst.Install(state);
                     inst.Commit(state);
                     SetParameters(openvpn);
                 }
             }
             catch
             {
                 try
                 {
                     inst.Rollback(state);
                 }
                 catch { }
                 throw;
             }
         }
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex.Message);
     }
 }
開發者ID:fikalefaza,項目名稱:openvpn-manager,代碼行數:37,代碼來源:OpenVPNManagerService.cs


注:本文中的System.Configuration.Install.AssemblyInstaller.Rollback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。