简体   繁体   中英

Installing a Windows Service - No error but it isn't in Service Control Manager

I've created a windows service in c# and I'm trying to install it for debug using the installutil as recommended here: http://msdn.microsoft.com/en-us/library/sd8zc8ha.aspx

The installutil says Install completed. However, nothing appears in the service control manager.

I've tried this on Server 2008 and XP with the same result.

Any ideas?

A colleague of mine had a more or less identical problem.

Did you add an installer to your project? For the service to be installed you need to add an installer to your Visual Studio Project. The easiest way to add an installer in Visual Studio is to open your service in Design Mode and right click the design area and select Add Installer. This will add a file ProjectInstaller.cs with itself contains a ServiceInstaller object and a ServiceProcessInstaller object. With the installer added you can set the Service Name, Description and other options that will be used when installing the service. If you now try to use InstallUtil your service should be installed and should show up in the Services list.

I had a similar issue (build installer, no errors, no service appears in services.msc ) but a different solution, as I had configured the installers.

In my case, the Service-project's Application Properties (Alt-Enter, Application-tab) Startup object was (not set) as shown below:

在此处输入图像描述

Picking the default .Program and rebuilding service and installer worked (service appeared in services.msc ).

Setting this property is one of the steps in the MSDN service installer walkthrough referenced in this SO answer. Make sure to follow all of the steps!

I can't speak specifically to any issues that are the fault of C# or .NET, but I have a writeup of what has to happen for a service to be installed and work in the form of an extensively documented framework (source code included) for writing services in Lua . I offer it up here as an example of another way to do it, because sometimes just seeing things from another point of view can be helpful.

Disclaimer: It is very much at an alpha quality level, and yes, I am its author.

The framework has all the code needed to interact with the Windows SCM to install and remove the service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM