DotNetCore.WindowsService icon indicating copy to clipboard operation
DotNetCore.WindowsService copied to clipboard

Service did not respond to the start or control request in a timely fashion

Open pmunshi007 opened this issue 7 years ago • 10 comments

I know this issue was raised before but currently I am also facing the same issue and I have tried all the solutions provided in #13 but no luck. Most annoying part here is the code base is same in master branch and my current branch. I just added few arguments to pass while running the program however the code to install/start/stop/uninstall service is the same. I am able to install and run service from master branch code base. But I am getting below error while trying to start service via command-line in my current branch. I am running this program in administrator terminal and also my basedirectory path does not contain space.

System.InvalidOperationException: Cannot start service testService on computer '.'. ---> System.ComponentModel.Win32Exception: The service did not respond to the start or control request in a timely fashion
         --- End of inner exception stack trace ---
         at System.ServiceProcess.ServiceController.Start(String[] args)
         at PeterKottas.DotNetCore.WindowsService.ServiceRunner`1.StartService(HostConfiguration`1 config, ServiceController sc)
         at PeterKottas.DotNetCore.WindowsService.ServiceRunner`1.UsingServiceController(HostConfiguration`1 config, Action`2 action)
         at PeterKottas.DotNetCore.WindowsService.ServiceRunner`1.Run(Action`1 runAction)
info: *.Service.Program[0]
      Return value from Run function -1

Even If I try to run the installed process from user interface it gives me below error.

windows could not start the service on local computer
error 1053 the service did not respond to the start or control request in a timely fashion

I am using 2.0.8 version of PeterKottas.DotNetCore.WindowsService library. What could be the reason here?

pmunshi007 avatar Sep 28 '18 16:09 pmunshi007

I am having same error with the latest version also 2.0.9 version of PeterKottas.DotNetCore.WindowsService library.

pmunshi007 avatar Oct 01 '18 16:10 pmunshi007

I have this trouble too

upd solution I rewrote Main method, replaced all slowly reflection before ServiceRunner<SomeService>.Run(config =>{

andreibulatov avatar Oct 03 '18 15:10 andreibulatov

Quite a common problem. My solution was to implement an own descendant of MicroService class where I've started a RunOnceTimer with all the initialization, IoC with assembly scanning, Akka, Nancy in a callback method. Not before or during Run(). Basically, you start a separate thread (like timer) and immediately tell Windows you're all done loading.

ka4ep avatar Oct 04 '18 06:10 ka4ep

Im having this problem too. @Apostol59 could you elaborate on your solution?

kalimist123 avatar Nov 07 '18 19:11 kalimist123

@kalimist123, no problem, bro. I had di container configuration in method main, container cofiguration was be relocated in OnStart.

Main method must contains minimum of operations before OnStart.

//from example
void Main()
{
//old di configuration
ServiceRunner<ExampleService>.Run(config =>
{
	var name = config.GetDefaultName();
	config.Service(serviceConfig =>
		{
			serviceConfig.ServiceFactory((extraArguments, microServiceController) =>
		{
			return new ExampleService();
		});
		serviceConfig.OnStart((service, extraArguments) =>
		{
//now di configuration
			Console.WriteLine("Service {0} started", name);
			service.Start();
		});
...
}
}

andreibulatov avatar Nov 08 '18 09:11 andreibulatov

@Apostol59 thank you

kalimist123 avatar Nov 12 '18 16:11 kalimist123

I was running into this error as well, however I was hitting it immediately when starting the service, it wasn't waiting 30 seconds. The issue was that I was using Network Service instead of Local System to run the windows service, must have been some sort of permissions issue...

justintoth avatar Mar 13 '19 20:03 justintoth

@Apostol59

I am having same error with the latest version of PeterKottas.DotNetCore.WindowsService library. Above your solution didn't work for me

can you please help me..

sagar-patel-sls avatar Mar 16 '19 12:03 sagar-patel-sls

@sagar-patel-sls Hi, I'm not a maintainer. May be @PeterKottas can help you, but, will be need more details, I think)

andreibulatov avatar Mar 16 '19 15:03 andreibulatov

Hii @PeterKottas

I am having same error with the latest version of PeterKottas.DotNetCore.WindowsService library. Above your solution didn't work for me

can you please help me..

sagar-patel-sls avatar Mar 18 '19 04:03 sagar-patel-sls