当前位置: 首页>>代码示例>>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;未经允许,请勿转载。