【问题标题】:installutil completes successfully but service is not installedinstallutil 成功完成但未安装服务
【发布时间】:2012-09-03 22:55:28
【问题描述】:

我正在尝试安装 Windows 服务。

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

我收到一条很好的消息,所有阶段(安装、提交)都已成功完成。

(没有提示我输入服务凭据)

之后我在服务控制台中看不到该服务。安装日志中没有任何用处。

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

我可以在 Visual Studio 之外运行服务没有问题。

installer.cs

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

这是 Visual Studio 提供的默认安装程序。

【问题讨论】:

  • 我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。另外,如果是安装的问题,那么这可能与WCF无关,所以我删除了那个标签。
  • 对不起!选词错误。安装脚本!!
  • madhairsilence.. 是您要的 installer.cs 吗?
  • 另外值得注意的是 - 如果您通过 cmd 提示符运行 - 请确保您以管理员身份运行。我刚遇到这个问题。

标签: c# windows-services


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    以下 SO 问题具有类似的场景和答案,也可能与通过 Google 搜索链接来到这里的人相关。

    Install Windows Service created in Visual Studio

    【讨论】:

      猜你喜欢
      • 2012-05-04
      • 1970-01-01
      • 2014-11-08
      • 1970-01-01
      • 2010-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多