I used the following piece of code in the service to debug the service successfully by running the service as a console application and verified everything works fine.But later when I installed the service and started it as a windows application the service is running as indicated by the services console but it is not doing the job it has to.I want to know what went wrong in this scenario.Thanks.
static void Main() { System.ServiceProcess.ServiceBase[] ServicesToRun;
if (Environment.UserInteractive)
{
ListenerSVC service = new ListenerSVC();
service.OnStart(null);
Console.WriteLine("Press any key to stop program");
Console.Read();
service.OnStop();
}
else
{
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ListenerSVC() };
ServiceBase.Run(ServicesToRun);
}
}