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


C# Install.AssemblyInstaller类代码示例

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


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

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

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

示例3: GetInstaller

 private static AssemblyInstaller GetInstaller()
 {
     AssemblyInstaller installer = new AssemblyInstaller(
         typeof(SetItUpService).Assembly, null);
     installer.UseNewContext = true;
     return installer;
 }
开发者ID:Wryxo,项目名称:bakalarka,代码行数:7,代码来源:Program.cs

示例4: GetInstaller

 /// <summary>
 /// 
 /// </summary>
 /// <param name="assembly"></param>
 /// <returns></returns>
 public static AssemblyInstaller GetInstaller(string serviceName)
 {
     //TODO: THis is not working
     AssemblyInstaller installer = new AssemblyInstaller();
     installer.UseNewContext = true;
     return installer;
 }
开发者ID:navkar,项目名称:BizTalkControlCenter,代码行数:12,代码来源:BCCServiceHelper.cs

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

示例6: GetInstaller

 private static AssemblyInstaller GetInstaller()
 {
     AssemblyInstaller installer = new AssemblyInstaller(
         typeof(Program).Assembly, null);
     installer.UseNewContext = true;
     return installer;
 }
开发者ID:robertbreker,项目名称:cloudstack,代码行数:7,代码来源:Program.cs

示例7: ServiceInstaller

        private static bool ServiceInstaller(bool uninstall = false)
        {
            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;

                if (!uninstall)
                {
                    myAssemblyInstaller.Install(mySavedState);
                    // Commit the 'MyAssembly' assembly.
                    myAssemblyInstaller.Commit(mySavedState);
                }
                else
                { myAssemblyInstaller.Uninstall(mySavedState); }
            }
            catch (FileNotFoundException)
            {
                throw;
            }
            catch (Exception)
            { return false; }
            
            return true;
        }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:33,代码来源:ServiceHelper.cs

示例8: InstallService

 /// <summary>
 /// 安装服务。
 /// </summary>
 /// <param name="fileName">文件名称</param>
 /// <param name="args">命令行参数</param>
 public static void InstallService(string fileName, string[] args)
 {
     TransactedInstaller transactedInstaller = new TransactedInstaller();
     AssemblyInstaller assemblyInstaller = new AssemblyInstaller(fileName, args);
     transactedInstaller.Installers.Add(assemblyInstaller);
     transactedInstaller.Install(new System.Collections.Hashtable());
 }
开发者ID:jihadbird,项目名称:firespider,代码行数:12,代码来源:ServiceUtil.cs

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

示例10: Installation

        public Installation() : base() 
        {
            #region Install on MSR.LST.Net.Rtp (a necessary dependency)
            AssemblyInstaller ai = new AssemblyInstaller();
            ai.UseNewContext = true;
            ai.Assembly = Assembly.Load("MSR.LST.Net.Rtp");
            Installers.Add(ai);
            #endregion
            
            #region Install MDShowManager (if it is in the same directory)
            FileInfo fi = new FileInfo(Assembly.GetExecutingAssembly().Location);
            FileInfo[] foundFiles = fi.Directory.GetFiles("MDShowManager.dll");
            if (foundFiles.Length == 1)
            {
                ai = new AssemblyInstaller();
                ai.UseNewContext = true;
                ai.Path = foundFiles[0].FullName;
                Installers.Add(ai);
            }
            #endregion

            #region Install Pipecleaner Agent Service (if it is in the same directory)
            fi = new FileInfo(Assembly.GetExecutingAssembly().Location);
            foundFiles = fi.Directory.GetFiles("Pipecleaner Agent Service.exe");
            if (foundFiles.Length == 1)
            {
                ai = new AssemblyInstaller();
                ai.UseNewContext = true;
                ai.Path = foundFiles[0].FullName;
                Installers.Add(ai);
            }
            #endregion
        }
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:33,代码来源:Installation.cs

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

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

示例13: btnInstall_Click

 /// <summary>
 /// 安装服务
 /// </summary>
 private void btnInstall_Click(object sender, EventArgs e)
 {
     if (!Vaild())
     {
         return;
     }
     try
     {
         string[] cmdline = { };
         string serviceFileName = txtPath.Text.Trim();
         string serviceName = GetServiceName(serviceFileName);
         if (string.IsNullOrEmpty(serviceName))
         {
             txtTip.Text = "指定文件不是Windows服务!";
             return;
         }
         if (ServiceIsExisted(serviceName))
         {
             txtTip.Text = "要安装的服务已经存在!";
             return;
         }
         TransactedInstaller transactedInstaller = new TransactedInstaller();
         AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline);
         assemblyInstaller.UseNewContext = true;
         transactedInstaller.Installers.Add(assemblyInstaller);
         transactedInstaller.Install(new System.Collections.Hashtable());
         txtTip.Text = "服务安装成功!";
     }
     catch (Exception ex)
     {
         txtTip.Text = ex.Message;
     }
 }
开发者ID:Zorbam,项目名称:TaskManager,代码行数:36,代码来源:FrmMain.cs

示例14: GetInstaller

 private static AssemblyInstaller GetInstaller(System.Reflection.Assembly assem)
 {
     AssemblyInstaller installer = new AssemblyInstaller(
         assem, null);
     installer.UseNewContext = true;
     return installer;
 }
开发者ID:erynet,项目名称:IMS,代码行数:7,代码来源:ServiceControl.cs

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


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