當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。