簡體   English   中英

安裝.NET Windows服務

[英]Installing .NET Windows Service

我正在嘗試安裝我使用的第一個服務:

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時,我沒有設置列出的服務。 我錯過了什么嗎?

確保您正確創建並配置了ServiceInstallerServiceProcessInstaller 這些是installutil用於實際注冊流程中的每個服務的內容。

我最近問了一個類似的問題: C#:運行和調試Windows服務

顯然問題是因為我沒有連接到服務的安裝程序

是我用來添加服務安裝程序等的教程。

我們能看到代碼嗎?

你對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;
}

您可能需要刷新services.msc窗口,如果您一直打開它,有時它不會更新它。 點擊F5刷新窗口,看看它是否存在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM