Install .NET Windows Service

I am trying to install the first service I wrote using:

installutil XMPPMonitor.exe

I get the following message:

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 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 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.

But I do not install the service specified when starting services.msc. Did I miss something?

+3
source share
4 answers

Make sure you correctly create and configure ServiceInstaller and ServiceProcessInstaller . This is what installutil uses to actually register each service in the process.

+2
source

I recently asked a similar question: C #: starting and debugging a Windows service

-, , Installer, .

- , Service Installer ..

+2

Can I see the code?

What do you have for the Description attribute? Have you pressed F5 (Update) in MMC Services?

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;
}
+1
source

You may need to update the services.msc window, sometimes it does not update it if you open it all the time. Press F5 to upgrade to the window and see if there are any.

+1
source

Source: https://habr.com/ru/post/1714533/


All Articles