Hello everybody,
I have created a sample windows service in C# in 2.0 framework.when I am running the service from the command prompt I am not able to see the service in the services list ,what may be the reason do i need to write any installer class .please help me.
Thanks,
Ranjith
Loading

AlanRank #669 · 3.6K reputationPosted Nov 13, 2007, 1:06 AM EST
Yes, you do need to install a Windows service for it to show up in the 'services' list.
There's a command line utility called InstallUtil.exe which can be used for this purpose.
So go to the VS or .NET SDK command prompt, navigate to the folder where the service resides, and type:
installutil myservicename.exe
to install and, if you should ever need to uninstall, type:
installutil /u myservicename.exe
Mahesh ChandRank #1 · 393.4K reputationPosted Nov 13, 2007, 3:13 AM EST
Here are step by step instructions:
http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx
ranjith n84 reputationPosted Nov 13, 2007, 11:09 PM EST
Now I moved further but struck up again..I am able to see the service but when I start the service it is closing immediately saying that service has nothing to perform .what is the reason?
AlanRank #669 · 3.6K reputationPosted Nov 14, 2007, 4:53 AM EST
I think we'll need to see some code, Ranjith, to answer that one.
I take it you've got some code in the OnStart() method?
I'd also double-check your Main() method to ensure you've covered all the steps in Mahesh's article.
ranjith n84 reputationPosted Nov 17, 2007, 12:19 AM EST
Thank you very much for answering my question patiently,I have cleared all my problems and developed the service,and I am able to run the application,it is working evrything is fine.But now I face a different problem.
I have developed my service as automatic startup mode.i.e when the system reboots it should start automatically.But when I restart the system,I can only see the service there in the list,but it is not starting automatically,again I am starting that manually.....what may be the reason.please tell me.
Here I am sending the code for my installer class.
private void InitializeComponent()
{
this.WinMQSOAPPollservice_Installer = new System.ServiceProcess.ServiceProcessInstaller();
this.WinMQSOAPPollInstaller = new System.ServiceProcess.ServiceInstaller();
//
// WinMQSOAPPollservice_Installer
//
this.WinMQSOAPPollservice_Installer.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.WinMQSOAPPollservice_Installer.Password = null;
this.WinMQSOAPPollservice_Installer.Username = null;
//
// WinMQSOAPPollInstaller
//
this.WinMQSOAPPollInstaller.ServiceName = "WinMQSOAPPollService";
this.WinMQSOAPPollInstaller.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.WinMQSOAPPollservice_Installer,
this.WinMQSOAPPollInstaller});
}
AlanRank #669 · 3.6K reputationPosted Nov 18, 2007, 12:56 AM EST
That code looks OK to me.
The most likely reason why it's not starting automatically is because you're attempting to use or do something which isn't available to the system at bootup time such as calling another service which hasn't yet started.
I'd have a look at the event log to see whether there are any clues there.