当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyInstaller.Uninstall方法代码示例

本文整理汇总了C#中System.Configuration.Install.AssemblyInstaller.Uninstall方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyInstaller.Uninstall方法的具体用法?C# AssemblyInstaller.Uninstall怎么用?C# AssemblyInstaller.Uninstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Configuration.Install.AssemblyInstaller的用法示例。


在下文中一共展示了AssemblyInstaller.Uninstall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Install

 static void Install(bool undo, string[] args)
 {
     try
     {
         Console.WriteLine(undo ? "Uninstalling" : "Installing");
         using (AssemblyInstaller inst = new AssemblyInstaller(typeof(WinSvc).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;
             }
         }
         Console.WriteLine("Done");
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex.Message);
     }
 }
开发者ID:rmbolger,项目名称:RemoteBootPicker,代码行数:32,代码来源:EntryPoint.cs

示例2: Install

        private void Install(AssemblyInstaller installer, IDictionary state, bool undo)
        {

            try
            {
                if (undo)
                {
                    _log.Write(LogLevel.Info, "Uninstalling {0}...", StringConstants.ServiceName);
                    installer.Uninstall(state);
                    _log.Write(LogLevel.Info, "{0} has been successfully removed from the system.", StringConstants.ServiceName);
                }
                else
                {
                    _log.Write(LogLevel.Info, "Installing {0}...", StringConstants.ServiceName);
                    installer.Install(state);

                    _log.Write(LogLevel.Info, "Commiting changes...");
                    installer.Commit(state);

                    _log.Write(LogLevel.Info, "Install succeeded.");
                }
            }
            catch (Exception ex)
            {
                _log.Write(LogLevel.Error, "An error occured during {1}. {0}", ex, undo?"uninstall" : "install");
                _log.Write(LogLevel.Info, "Trying to roll back...");
                TryRollback(installer, state);
            }
        }
开发者ID:vjohnson01,项目名称:Tools,代码行数:29,代码来源:InstallUtil.cs

示例3: 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

示例4: UninstallWindowsService

        public static bool UninstallWindowsService()
        {
            StopService();
            IDictionary mySavedState = new Hashtable();

            try
            {
                // Set the commandline argument array for 'logfile'.
                string[] commandLineOptions = new string[1] { string.Format("/LogFile={0}", _logFile) };

                // Create an object of the 'AssemblyInstaller' class.
                AssemblyInstaller myAssemblyInstaller = new
                AssemblyInstaller(_installAssembly, commandLineOptions);


                myAssemblyInstaller.UseNewContext = true;

                // Install the 'MyAssembly' assembly.
                myAssemblyInstaller.Uninstall(mySavedState);

                // Commit the 'MyAssembly' assembly.
                myAssemblyInstaller.Commit(mySavedState);
            }
            catch (Exception e)
            { return false; }

            return true;
        }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:28,代码来源:ServiceHelper.cs

示例5: UninstallService

        /// <summary>
        /// Remove um serviço do windows do registro
        /// </summary>
        public static void UninstallService(String fileName)
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
            String serviceName = Path.GetFileNameWithoutExtension(fileName);
            String[] arguments = new string[] { "/LogFile=" + serviceName + "_Install.log" };

            AssemblyInstaller installer = new AssemblyInstaller(fileName, arguments);
            installer.UseNewContext = true;
            installer.Uninstall(null);
        }
开发者ID:renatosans,项目名称:contratos,代码行数:13,代码来源:ServiceHandler.cs

示例6: UnInstallService

 /// <summary>
 /// 卸载windows服务
 /// </summary>
 /// <param name="filepath">获取或设置要安装的程序集的路径。</param>
 public static void UnInstallService(String serviceName, string filepath)
 {
     if (ServiceIsExisted(serviceName))
     {
         AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
         myAssemblyInstaller.UseNewContext = true;
         myAssemblyInstaller.Path = filepath;
         myAssemblyInstaller.Uninstall(null);
         myAssemblyInstaller.Dispose();
     }
 }
开发者ID:limingnihao,项目名称:Net,代码行数:15,代码来源:ServiceUtil.cs

示例7: 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

示例8: UnInstallmyService

 /// <summary>
 /// 卸载Windows服务
 /// </summary>
 /// <param name="filepath">程序文件路径</param>
 public static void UnInstallmyService(IDictionary stateSaver,string filepath)
 {
     try
     {
         AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
         AssemblyInstaller1.UseNewContext = true;
         AssemblyInstaller1.Path = filepath;
         AssemblyInstaller1.Uninstall(stateSaver);
         AssemblyInstaller1.Dispose();
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message.ToString());
     }
 }
开发者ID:fuwei199006,项目名称:lottery,代码行数:19,代码来源:Windows.cs

示例9: Uninstall

 public static void Uninstall()
 {
     using (AssemblyInstaller installer =
             new AssemblyInstaller(typeof(OpenVpnService).Assembly, null))
     {
         installer.UseNewContext = true;
         var state = new System.Collections.Hashtable();
         try
         {
             installer.Uninstall(state);
         }
         catch
         {
             throw;
         }
     }
 }
开发者ID:xkjyeah,项目名称:openvpnserv2,代码行数:17,代码来源:ProjectInstaller.cs

示例10: UnInstallService

 /// <summary>
 /// 卸载windows服务:
 /// </summary>
 /// <param name="filepath"></param>
 public void UnInstallService(string filepath)
 {
     try
     {
         string serviceName = GetServiceName(filepath);
         if (ServiceIsExisted(serviceName))
         {
             //UnInstall Service
             AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller() { UseNewContext = true, Path = filepath };
             myAssemblyInstaller.Uninstall(null);
             myAssemblyInstaller.Dispose();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("unInstallServiceError/n" + ex.Message);
     }
 }
开发者ID:yangdaichun,项目名称:ZHXY.ZSXT,代码行数:22,代码来源:ManageService.cs

示例11: 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

示例12: 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

示例13: Uninstall

        /// <summary>
        /// Uninstalls the assembly specified by <see cref="P:assemblyPath" />
        /// </summary>
        /// <param name="assemblyPath">Full path to the assembly to uninstall</param>
        public static void Uninstall(string assemblyPath)
        {
            try
            {
                AssemblyInstaller installer = new AssemblyInstaller(assemblyPath, new String[] { })
                {
                    UseNewContext = true
                };

                installer.Uninstall(null);
                installer.Commit(null);
            }
            catch (FileNotFoundException exception)
            {
                Console.WriteLine("[!] Installer state file not found, uninstalling service without storing the state" + exception.Message);
            }
            catch (Exception exception2)
            {
                Console.WriteLine("[!] Unable to uninstall service: " + exception2.Message);
            }
        }
开发者ID:TcmExtensions,项目名称:TcmCDService,代码行数:25,代码来源:Installation.cs

示例14: 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

示例15: OnAction

 public void OnAction(Hashtable parameters)
 {
     System.Configuration.Install.AssemblyInstaller asmInstaller = new AssemblyInstaller(Assembly.GetExecutingAssembly(), new string[1] { "/LogToConsole=false" });
     Hashtable rollback = new Hashtable();
     if (GameServerService.GetDOLService() == null)
     {
         Console.WriteLine("No service named \"DOL\" found!");
         return;
     }
     Console.WriteLine("Uninstalling DOL system service...");
     try
     {
         asmInstaller.Uninstall(rollback);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error uninstalling system service");
         Console.WriteLine(e.Message);
         return;
     }
     Console.WriteLine("Finished!");
 }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:22,代码来源:ServiceUninstall.cs


注:本文中的System.Configuration.Install.AssemblyInstaller.Uninstall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。