C# 安装.NET Windows服务

C# 安装.NET Windows服务,c#,.net,C#,.net,我正在尝试安装我编写的第一个服务,使用: installutil XMPPMonitor.exe 我得到以下信息: Running a transacted installation. Beginning the Install phase of the installation. See the contents of the log file for the E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonit

我正在尝试安装我编写的第一个服务,使用:

installutil XMPPMonitor.exe
我得到以下信息:

Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.exe assembly's progress.
The file is located at E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.InstallLog.

The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.exe assembly's progress.
The file is located at E:\Documents\Projects\XMPPMonitor\XMPPMonitor\bin\Debug\XMPPMonitor.InstallLog.

The Commit phase completed successfully.


The transacted install has completed.

但我在运行services.msc时没有设置列出的服务。我遗漏了什么吗?

请确保正确创建和配置了和。这些是installutil用于在流程中实际注册每个服务的内容。

我们可以看到代码吗

“描述”属性有哪些属性?您是否在服务MMC中单击了F5(刷新)

public class WindowsServiceInstallerEx : ServiceInstaller
{

  [ComponentModel.Description("A lengthy description of the service that will display in the Description column of the Services MMC applet.")]
  public string ServiceDescription
  {
    get { return serviceDescription; }
    set { serviceDescription = value; }
  }

  public override void Install(System.Collections.IDictionary stateSaver)
  {
    base.Install (stateSaver);

    Microsoft.Win32.RegistryKey serviceKey = null;
    try
    {
      string strKey = string.Format(@"System\CurrentControlSet\Services\{0}", this.ServiceName);

      serviceKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strKey, true);
      serviceKey.SetValue("Description", this.ServiceDescription);
    }
    finally
    {
      if (serviceKey != null)
        serviceKey.Close();
    }
  }

  private string serviceDescription;
}

您可能需要刷新services.msc窗口,如果您一直打开它,有时它不会更新它。按F5刷新窗口,查看是否有。最近我问了一个类似的问题:

显然,问题是因为我没有一个安装程序连接到服务

是我用来添加服务安装程序等的教程