加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

C# – Windows服务安装程序不注册服务

发布时间:2020-12-15 07:49:27 所属栏目:百科 来源:网络整理
导读:我试图使用 Windows服务的安装程序,并希望避免使用InstallUtil.exe.安装程序似乎正常工作(可执行文件和dll位于正确的目录中),但该服务不会显示在“计算机管理”下. 这是我到目前为止所做的: 服务类名称是默认值 – Service1. 在项目安装程序中,服务安装程序
我试图使用 Windows服务的安装程序,并希望避免使用InstallUtil.exe.安装程序似乎正常工作(可执行文件和dll位于正确的目录中),但该服务不会显示在“计算机管理”下.

这是我到目前为止所做的:

服务类名称是默认值 – Service1.

在项目安装程序中,服务安装程序的ServiceName与类名称Service1匹配.

在自定义操作下,服务的主要输出被添加到安装,提交,回滚和卸载.

我使用http://support.microsoft.com/kb/816169作为参考.

有任何想法吗?

解决方法

您的服务项目是否具有安装程序类?你应该有一个看起来像这样:
[RunInstaller(true)]
public partial class Service1Installer : Installer
{
    public Service1Installer()
    {
        InitializeComponent();
        ServiceProcessInstaller process = new ServiceProcessInstaller();
        process.Account = ServiceAccount.LocalSystem;

        ServiceInstaller serviceAdmin = new ServiceInstaller();
        serviceAdmin.StartType = ServiceStartMode.Manual;
        serviceAdmin.ServiceName = "Service1";
        serviceAdmin.DisplayName = "Service1";
        serviceAdmin.Description = "Service1";

        Installers.Add(serviceAdmin);
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读