Windows Service not appearing in services list after install

C#Visual Studio-2008Windows ServicesSetup Deployment

C# Problem Overview


I've created a windows service in C#, using Visual Studio 2008 I pretty much followed this: http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx

I created a setup project, as instructed to in the article, and ran it... it installs my service to C:\Program Files\Product etc.... however, it does not then appear in the services list..

What am I missing?

C# Solutions


Solution 1 - C#

The most important part of the article you linked, is here

> To add a custom action to the setup project > >> 1.In Solution Explorer, right-click the setup project, point to View, then >> choose Custom Actions. The Custom >> Actions editor appears. >> >> 2.In the Custom Actions editor, right-click the Custom Actions node >> and choose Add Custom Action. The >> Select Item in Project dialog box >> appears. >> >> 3.Double-click the application folder in the list box to open it, select >> primary output from MyNewService >> (Active), and click OK. The primary >> output is added to all four nodes of >> the custom actions � Install, Commit, >> Rollback, and Uninstall. >> >> 4.Build the setup project.

If you skip these steps, your setup project will build and copy your files to the correct directory; however, they will not register your binary as a service without these steps.


I should also note that this works for older versions of Visual Studio that had/have the built-in Setup/Deployment project template. The newer versions of Visual Studio have different setup/deployment projects (some requiring third party software.)

I'd recommend looking into WiX Toolset and check here for WiX Installation of Windows Services.

Solution 2 - C#

I got owned in the face by this one, so I'm putting it here just in case anyone else runs into it.

If you followed the instructions in the guides but are still having issues installing, ensure your Installer class is public. Internal won't work.

Solution 3 - C#

I had this same issue and then I realized that I never set the parent for the ServiceInstaller.

Double-click on your project installer. The designer should show a Service Installer and Process Installer. When you click on either and view the properties you should note the Parent attribute which must both be set to the class name of the Project Installer.

Or, if you do it in code, make sure you set:

serviceInstaller.Parent = this;

and

serviceProcessInstaller.Parent = this;

Solution 4 - C#

When installing services, I would highly recommend using NSSM, which worked well for me for all my WinService needs. It can install any executable (even if .bat, .cmd) as a service, and guarantees your service is always up and running.

To use this tool:

  1. Download from here

  2. And follow the instructions here

Then check the services list, it should be there, up, and running.

Solution 5 - C#

Follow these instructions, they worked for me. For the setup specifically, that part is near the bottom of the article.

MSDN: Walkthrough: Creating a Windows Service

Solution 6 - C#

In Visual Studio 2013 I ran into the same problem using InstallShield template for service application. But it works like charm when using Setup Project template https://visualstudiogallery.msdn.microsoft.com/9abe329c-9bba-44a1-be59-0fbf6151054d

so download Setup Project template close your Studio, run this installation and start your Studio, this will work.

Dunn.

Solution 7 - C#

Here is a good tutorial from tgeek001 from CodeProject.com that helped me. It includes several things I didn't see in the posts above:

  1. Event handler code to stop the service before uninstalling it
  2. Specific conditions and properties in the Custom Actions code to set in order to prevent failures (these fixed the Error 1001 that I experienced while following the instructions in the accepted answer above)
  3. Win Service property "Remove Previous Version" dropdown set to true

http://www.codeproject.com/Tips/575177/Window-Service-Deployment-using-VS

The following is from the tutorial for Custom Actions Settings (case matters):

  • Install, set the Condition property to the following: "NOT (Installed or PREVIOUSVERSIONSINSTALLED)"
  • Uninstall, set the Condition property to: "NOT UPGRADINGPRODUCTCODE"
  • Commit: set "Custom Action Data" field to: /OldProductCode="[PREVIOUSVERSIONSINSTALLED]"

Lastly, in the WinService project, make sure to set the dropdown "Remove Previous Versions" to true.

cheers

Solution 8 - C#

I discovered that your installer class much be in the same project as the Service. The installer cannot exist in a library project referenced by the Service.

Solution 9 - C#

remember to check the name you've given your service before you search. (right click-> properties->check the service name

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexView Question on Stackoverflow
Solution 1 - C#NateView Answer on Stackoverflow
Solution 2 - C#xofzView Answer on Stackoverflow
Solution 3 - C#Clarice BouwerView Answer on Stackoverflow
Solution 4 - C#ZafarView Answer on Stackoverflow
Solution 5 - C#Jon SeigelView Answer on Stackoverflow
Solution 6 - C#DungView Answer on Stackoverflow
Solution 7 - C#sondlerdView Answer on Stackoverflow
Solution 8 - C#kspearrinView Answer on Stackoverflow
Solution 9 - C#Sowmiya RView Answer on Stackoverflow