安装.NET Windows服务

时间:2009-08-06 17:37:33

标签: 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\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时,我没有设置列出的服务。我错过了什么吗?

4 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:2)

我最近问了一个类似的问题:C#: Running and Debugging a Windows Service

显然问题是因为我没有附加安装程序

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

答案 2 :(得分:1)

我们可以看到代码吗?

您对Description属性有什么用处?您是否在服务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;
}

答案 3 :(得分:1)

您可能需要刷新services.msc窗口,如果您一直打开它,有时它不会更新它。点击F5刷新窗口,看看它是否存在。