Installed Win Service not displaying in Service Manager
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 开发者_StackOverflow中文版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.
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.
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
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
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.
精彩评论