简体   繁体   English

installutil成功完成但未安装服务

[英]installutil completes successfully but service is not installed

I am trying to install a windows service. 我正在尝试安装Windows服务。

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

i get a nice message that all phases (install, commit) completed successfully. 我得到一个很好的消息,所有阶段(安装,提交)成功完成。

(i do not get prompted to enter service credentials) (我不会被提示输入服务凭据)

afterwards i do not see the service in services console. 之后我没有在服务控制台中看到该服务。 nothing useful in install log. 在安装日志中没什么用处。

the solution is built on a 64bit box, and i am trying to install the service on a 64bit machine. 该解决方案建立在64位盒子上,我试图在64位机器上安装该服务。 however, i do not see 64bit as an option in solution properties. 但是,我没有看到64位作为解决方案属性的选项。 i did manually edit all the csproj files to select "x64" for [platform] nodes.. 我手动编辑了所有csproj文件,为[platform]节点选择“x64”。

i can run the service out of visual studio no problem. 我可以运行视觉工作室服务没问题。

installer.cs installer.cs

[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
    public Installer() {
        InitializeComponent();
    }
}

this is the default installer provided by visual studio. 这是visual studio提供的默认安装程序。

You need to add some Installer objects to the Installers collection. 您需要将一些Installer对象添加到Installers集合中。 The example here is what you want for installing a windows service. 这里的示例是您要安装Windows服务的示例。 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);
    }
}

The following SO Question has similar scenarios and answers that may also be relevant to someone coming here from a Google search link. 以下SO问题具有类似的场景和答案,这些场景和答案也可能与来自Google搜索链接的人员相关。

Install Windows Service created in Visual Studio 安装在Visual Studio中创建的Windows服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM