installutil completes successfully but service is not installed

前端 未结 2 2066
陌清茗
陌清茗 2021-02-18 19:35

I am trying to install a windows service.

running c:\\windows\\microsoft.net\\Framework64\\v4.0.30319\\InstallUtil.exe c:\\foo\\MyAssembly.exe

i get a nice mes

相关标签:
2条回答
  • 2021-02-18 19:53

    The following SO Question has similar scenarios and answers that may also be relevant to someone coming here from a Google search link.

    Install Windows Service created in Visual Studio

    0 讨论(0)
  • 2021-02-18 19:58

    You need to add some Installer objects to the Installers collection. The example here is what you want for installing a windows service. Something like

    [RunInstaller(true)]
    public class Installer : System.Configuration.Install.Installer
    {
        private ServiceInstaller serviceInstaller;
        private ServiceProcessInstaller processInstaller;
    
        public Installer()
        {
            // Instantiate installers for process and services.
            processInstaller = new ServiceProcessInstaller();
            serviceInstaller = new ServiceInstaller();
    
            // The services run under the system account.
            processInstaller.Account = ServiceAccount.LocalSystem;
    
            // The services are started manually.
            serviceInstaller.StartType = ServiceStartMode.Manual;
    
            // ServiceName must equal those on ServiceBase derived classes.
            serviceInstaller.ServiceName = "Hello-World Service 1";
    
            // Add installers to collection. Order is not important.
            Installers.Add(serviceInstaller);
            Installers.Add(processInstaller);
        }
    }
    
    0 讨论(0)
提交回复
热议问题