installutil 成功完成但未安装服务 [英] installutil completes successfully but service is not installed

查看:28
本文介绍了installutil 成功完成但未安装服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装 Windows 服务.

I am trying to install a windows service.

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

running 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.

该解决方案建立在 64 位机器上,我正在尝试在 64 位机器上安装该服务.但是,我没有将 64 位视为解决方案属性中的一个选项.我确实手动编辑了所有 csproj 文件,为 [平台] 节点选择x64"..

the solution is built on a 64bit box, and i am trying to install the service on a 64bit machine. however, i do not see 64bit as an option in solution properties. i did manually edit all the csproj files to select "x64" for [platform] nodes..

我可以在 Visual Studio 之外运行该服务,没问题.

i can run the service out of visual studio no problem.

安装程序.cs

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

这是visual studio 提供的默认安装程序.

this is the default installer provided by visual studio.

推荐答案

您需要将一些 Installer 对象添加到 Installers 集合中.此处的示例是您安装 Windows 服务所需的示例.类似的东西

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);
    }
}

这篇关于installutil 成功完成但未安装服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆