首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >installutil已成功完成,但未安装服务

installutil已成功完成,但未安装服务
EN

Stack Overflow用户
提问于 2012-09-11 11:43:37
回答 2查看 19K关注 0票数 22

我正在尝试安装windows服务。

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

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

(系统未提示我输入服务凭据)

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

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

我可以在visual studio之外运行该服务,没有问题。

installer.cs

代码语言:javascript
复制
[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
    public Installer() {
        InitializeComponent();
    }
}

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-09-11 12:09:19

您需要向Installers集合添加一些Installer对象。示例here就是您安装windows服务所需的内容。就像这样

代码语言:javascript
复制
[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);
    }
}
票数 29
EN

Stack Overflow用户

发布于 2017-01-23 02:12:48

下面的SO问题有类似的场景和答案,可能也与来自Google搜索链接的人相关。

Install Windows Service created in Visual Studio

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12362455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档