I have created a Windows Service in ASP.NET 4.0 and I am using the following command to install the service after starting a command prompt as administrator:
C:\Windows\system32>sc create EnviroTracker1 binpath= “D:\Freelance Work\SuperExpert\git
EnviroTrack\EnviroTrack\EnviroTrackerService\bin\Release\EnviroTrackService.exe”[SC] CreateService SUCCESS
After that, I go to Administrator tools -> services, and try to start the service, but I’m getting the following error:
---------------------------Services
---------------------------Windows could not start the EnviroTracker1 service on Local Computer.
Error 1053: The service did not respond to the start or control
request in a timely fashion.---------------------------OK
---------------------------
I also tried installutil. In that case also, service is installed and its start type is automatic and service status is automatic in services property window. Please suggest me a solution to this.
Thanks.
You will need have a class that derives from ServiceBase and add code to the
OnStartandOnStopmethods. Once you get that working you can right click anywhere in designer view and choose “Add Installer” which will add the necessary code to the assembly that allows installutil to register the service.It is possible that in the
OnStartmethod you are waiting too long to return. You need to make sure that you are only doing enough work to get the logic of your service started. This means you may have to spin up a new thread or otherwise somehow start your logic asynchronously.