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


C# AssemblyInstaller.Dispose方法代碼示例

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


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

示例1: InstallService

 /// <summary>
 /// 安裝服務:
 /// </summary>
 /// <param name="filepath"></param>
 public void InstallService(string filepath)
 {
     try
     {
         string serviceName = GetServiceName(filepath);
         ServiceController service = new ServiceController(serviceName);
         if (!ServiceIsExisted(serviceName))
         {
             //Install Service
             AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller() { UseNewContext = true, Path = filepath };
             myAssemblyInstaller.Install(new Hashtable());
             myAssemblyInstaller.Commit(new Hashtable());
             myAssemblyInstaller.Dispose();
             //--Start Service
             service.Start();
         }
         else
         {
             if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending)
             {
                 service.Start();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("installServiceError/n" + ex.Message);
     }
 }
開發者ID:yangdaichun,項目名稱:ZHXY.ZSXT,代碼行數:33,代碼來源:ManageService.cs

示例2: InstallService

 /// <summary>
 /// 安裝Windows服務
 /// </summary>
 /// <param name="stateSaver">狀態集合</param>
 /// <param name="filepath">程序文件路徑</param>
 public static void InstallService(IDictionary stateSaver, String filepath)
 {
     AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
     AssemblyInstaller1.UseNewContext = true;
     AssemblyInstaller1.Path = filepath;
     AssemblyInstaller1.Install(stateSaver);
     AssemblyInstaller1.Commit(stateSaver);
     AssemblyInstaller1.Dispose();
 }
開發者ID:gavincode,項目名稱:ExcelTool,代碼行數:14,代碼來源:ServiceInstaller.cs

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

示例4: InstallService

        public static void InstallService()
        {
            string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            string strDir = System.IO.Path.GetDirectoryName(exePath);
            string filepath = strDir + "\\MPlayerWWService.exe";

            IDictionary mSavedState = new Hashtable();
            AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
            myAssemblyInstaller.UseNewContext = true;
            myAssemblyInstaller.Path = filepath;
            myAssemblyInstaller.Install(mSavedState);
            myAssemblyInstaller.Commit(mSavedState);
            myAssemblyInstaller.Dispose();
        }
開發者ID:william0wang,項目名稱:meditor,代碼行數:14,代碼來源:Program.cs

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

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

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

示例8: InstallService

 /// <summary>
 /// 安裝windows服務
 /// </summary>
 /// <param name="serviceName">服務名稱</param>
 /// <param name="savedState">它用於保存執行提交、回滾或卸載操作所需的信息。</param>
 /// <param name="filepath">獲取或設置要安裝的程序集的路徑。</param>
 public static void InstallService(String serviceName, IDictionary savedState, string filepath)
 {
     ServiceController service = new ServiceController(serviceName);
     if (!ServiceIsExisted(serviceName))
     {
         AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
         myAssemblyInstaller.UseNewContext = true;
         myAssemblyInstaller.Path = filepath;
         myAssemblyInstaller.Install(savedState);
         myAssemblyInstaller.Commit(savedState);
         myAssemblyInstaller.Dispose();
         service.Start();
     }
     else
     {
         if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending)
         {
             service.Start();
         }
     }
 }
開發者ID:limingnihao,項目名稱:Net,代碼行數:27,代碼來源:ServiceUtil.cs

示例9: InstallService

 /// <summary>
 /// 安裝服務
 /// </summary>
 /// <param name="filePath">服務文件路徑</param>
 /// <param name="serviceName">服務名稱</param>
 /// <param name="options">選項</param>
 public static void InstallService(string filePath, string serviceName, string[] options)
 {
     try
     {
         if (!IsServiceExisted(serviceName))
         {
             IDictionary mySavedState = new Hashtable();
             AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
             myAssemblyInstaller.UseNewContext = true;
             myAssemblyInstaller.Path = filePath;
             myAssemblyInstaller.CommandLine = options;
             myAssemblyInstaller.Install(mySavedState);
             myAssemblyInstaller.Commit(mySavedState);
             myAssemblyInstaller.Dispose();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("請以管理員身份啟動程序再執行此操作\n" + ex.Message);
     }
 }
開發者ID:eatage,項目名稱:sqlbackup,代碼行數:27,代碼來源:WinService.cs

示例10: uninstallmyservice

 /// <summary>
 /// 卸載服務
 /// </summary>
 /// <param name="filepath"></param>
 public static void uninstallmyservice(string filepath)
 {
     try
     {
         AssemblyInstaller assemblyinstaller1 = new AssemblyInstaller();
         assemblyinstaller1.UseNewContext = true;
         assemblyinstaller1.Path = filepath;
         assemblyinstaller1.Uninstall(null);
         assemblyinstaller1.Dispose();
     }
     catch(Exception e)
     {
         throw new Exception("請以管理員身份啟動程序再執行此操作\n" + e.Message);
     }
 }
開發者ID:eatage,項目名稱:sqlbackup,代碼行數:19,代碼來源:WinService.cs

示例11: InstallmyService

 /// <summary>  
 /// 安裝Windows服務  
 /// </summary>  
 /// <param name="stateSaver">集合</param>  
 /// <param name="filePath">程序文件路徑</param>  
 public static void InstallmyService(IDictionary stateSaver, string filePath)
 {
     var asmInstaller = new AssemblyInstaller();
     asmInstaller.UseNewContext = true;
     asmInstaller.Path = filePath;
     asmInstaller.Install(stateSaver);
     asmInstaller.Commit(stateSaver);
     asmInstaller.Dispose();
 }
開發者ID:yonglehou,項目名稱:ImcTF,代碼行數:14,代碼來源:WinServiceControl.cs

示例12: UnInstallmyService

 /// <summary>  
 /// 卸載Windows服務  
 /// </summary>  
 /// <param name="filepath">程序文件路徑</param>  
 public static void UnInstallmyService(string filepath)
 {
     var asmInstaller = new AssemblyInstaller();
     asmInstaller.UseNewContext = true;
     asmInstaller.Path = filepath;
     asmInstaller.Uninstall(null);
     asmInstaller.Dispose();
 }
開發者ID:yonglehou,項目名稱:ImcTF,代碼行數:12,代碼來源:WinServiceControl.cs

示例13: InstallService

 /// <summary>
 /// 安裝windows服務
 /// </summary>
 private void InstallService(IDictionary stateSaver, string filepath, string serviceName)
 {
     try
     {
         ServiceController service = new ServiceController(serviceName);
         if (!ServiceIsExisted(serviceName))
         {
             AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
             myAssemblyInstaller.UseNewContext = true;
             myAssemblyInstaller.Path = filepath;
             myAssemblyInstaller.Install(stateSaver);
             myAssemblyInstaller.Commit(stateSaver);
             myAssemblyInstaller.Dispose();
             service.Start();
         }
         else
         {
             if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending)
                 service.Start();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("InstallServiceError\r\n" + ex.Message);
     }
 }
開發者ID:yonglehou,項目名稱:BPMSV1,代碼行數:29,代碼來源:ServicesHelper.cs

示例14: UnInstallService

 /// <summary>
 /// 卸載Windows服務
 /// </summary>
 /// <param name="filepath">程序文件路徑</param>
 public static void UnInstallService(String filepath)
 {
     AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
     AssemblyInstaller1.UseNewContext = true;
     AssemblyInstaller1.Path = filepath;
     AssemblyInstaller1.Uninstall(null);
     AssemblyInstaller1.Dispose();
 }
開發者ID:gavincode,項目名稱:ExcelTool,代碼行數:12,代碼來源:ServiceInstaller.cs

示例15: Main

        static void Main(string[] args)
        {
            var cancelled = false;
            var config = args.Where((s) => s.Contains("--config-path=")).SingleOrDefault();
            if (!String.IsNullOrEmpty(config))
            {
                var configFileName = config.Split('=')[1];
                if (!String.IsNullOrEmpty(configFileName))
                {
                    _currentConfigPath = Path.Combine(Directory.GetCurrentDirectory(), configFileName);
                    if (!File.Exists(_currentConfigPath))
                        throw new FileNotFoundException(String.Format("File {0} is not found in current directory", configFileName));
                }
            }

            ServiceRunner runner = new ServiceRunner(args, LoadTaskHandlerDescriptors());

            if (!runner.Options.IsValid)
            {
                Console.WriteLine(String.Format(runner.GetHelp(), System.IO.Path.GetFileName(Environment.GetCommandLineArgs()[0])));
                return;
            }

            if (runner.Options.RunConsole) // console mode
            {
                Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => {
                    e.Cancel = true;
                    cancelled = true;
                    Logger.Instance.Info("Exiting...");
                    runner.Dispose();
                    return;
                };

                runner.Start();
                WatchServiceAssemblies(Directory.GetCurrentDirectory(), (fname) => {
                    // Reload the task handlers, not ready yet
                    if (runner.Options.Mode != MSA.Zmq.JsonRpc.ServiceMode.Router)
                    {
                        if (Environment.UserInteractive)
                        {
                            PrintMessage("Reloading task handlers...", true);
                        }

                        runner.Reload(LoadTaskHandlerDescriptors());
                    }
                });

                if (runner.Options.Mode != ServiceMode.None)
                    while (!cancelled) { }
            }
            else
            {
                var serviceAction = runner.Options.ServiceAction;
                if (serviceAction == ServiceAction.Install)
                {
                    // install the service with arguments
                    AssemblyInstaller installer = new AssemblyInstaller(typeof(Program).Assembly, args);
                    IDictionary state = new Hashtable();

                    try
                    {
                        installer.UseNewContext = true;
                        if (runner.Options.Mode == ServiceMode.Router || runner.Options.Mode == ServiceMode.MultiWorker ||
                            runner.Options.Mode == ServiceMode.Worker || runner.Options.Mode == ServiceMode.Publisher)
                        {
                            // remove the --install-service arg
                            var newArgs = args.Where(s => !s.StartsWith("--install-service")).ToArray();
                            installer.Installers.Add(new ZMQServiceInstaller(runner.Options.ServiceName, newArgs));
                        }

                        if (serviceAction == ServiceAction.Install)
                        {
                            installer.Install(state);
                            installer.Commit(state);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Instance.Error(ex);
                        installer.Rollback(state);
                        throw;
                    }
                    finally
                    {
                        installer.Dispose();
                    }
                }
                else if (serviceAction == ServiceAction.Help)
                {
                    Console.WriteLine(String.Format(runner.GetHelp(), System.IO.Path.GetFileName(Environment.GetCommandLineArgs()[0])));
                }
                else // run the service
                {
                    ServiceBase.Run(new ZMQService(runner));
                }
            }
        }
開發者ID:kadekcipta,項目名稱:ZmqJsonRpc,代碼行數:97,代碼來源:Program.cs


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