3
votes

I have a Windows Service created in c#.

It's relatively simple compared to some of the other ones that I've worked on.

I built a setup project to install it for some testing.

I added the primary output from the service project and all the dependencies were added correctly.

I went to View > Custom Actions and added my Primary output to Install, Commit, Rollback, and Uninstall.

The project built and I right clicked the project and clicked Install.

The installation came back successful, I can view the service on the control panel under Add/Remove programs, but when I go into the Service Manager... nothing...

Can anyone provide some insite or anything else that may cause a successfuly installed service to NOT display on the Service Manager.

4
Did it install the service executable to your disk? Can you use installutil on the .exe and see if it gives you an error?James Michael Hare
Use MSI logging to see what possibly went wrong. I don't know in particular about authoring an MSI this way, so potentially anything could be the issue. But the log file will give further clues.0xC0000022L
yes it installed the executable to the disk where I expected it to. when I try to use installutil it opens a new command window with some text and closes it again before i am able to read it, and nothing changes in the command window that i typed the command intoPatrick
donot know exactly but I think you have to create shortcut of primary output and then place shortcut to install .as far as command window is concerned i doubt you have to access it via CMD promptAfnan Bashir
Are your .NET tools in your path? If not you can run installutil from the framework directory and just fully qualify path to your app. Go to where the .exe is installed from a command prompt and then type: c:\windows\Microsoft.NET\Framework\v4.0.30319\installutil -i YourProgram.exeJames Michael Hare

4 Answers

4
votes

Forgive me if this goes without saying, but you haven't mentioned what code you are executing in your custom actions. Your service assembly must have a class which derives from System.Configuration.Install.Installer, and that class must have the [RunInstaller(true)] attribute on it. Within that class, you will need to create an instance of System.ServiceProcess.ServiceInstaller and System.ServiceProcess.ServiceProcessInstaller, set the appropriate parameters on those instances, and add them to the Installers collection. The ServiceInstaller and ServiceProcessInstaller MSDN pages have a very basic example, but it should be enough to get you there if this is what is needed.

1
votes

Make sure you had provided some value in "Display name" property.

Use the following command "sc query <service_name>" from command prompt to see whether your windows service got properly installed. If you are not sure on the service name use the following command "sc query state= all >c:\ServicesList.txt" after executing this command search the ServicesList.txt in your C:\ drive.

If that too doesn't work try looking for the service name in registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

1
votes

You said you added your primary output to Install, etc. But did you create an Installer derived class to do the actual installing of the windows service? I'm not talking the setup project itself, but in your project there should be an installer class that actually does the service install for you.

I had a post on my blog about creating a framework for easy installable services, it has examples on creating the isntaler class.

http://blackrabbitcoder.net/archive/2010/10/07/c-windows-services-2-of-2-self-installing-windows-service-template.aspx

0
votes

In my case, solution of the problem was simple, i forgot to add access modifier 'Public' to the class. After adding access modifier, service is visible now in services list.