.NET Framework Developer Center > .NET Development Forums > .NET Base Class Library > Error 1053: The service did not respond to the start or control request in a timely fashion.
Ask a questionAsk a question
 

AnswerError 1053: The service did not respond to the start or control request in a timely fashion.

  • Thursday, November 05, 2009 2:20 PMChandra.Hatwar Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I had created one windows service-"DayBegin" which executes a batch file. When I am trying to start the service it throws an alert "Could not start the DayBegin service on local computer. Error 1053: The service did not respond to the start or control request in a timely fashion. This batch files works fine when executed directly and from the schedular aswell. I have tried this on both Windows XP Professional and Windows server 2003 but throwing same exception.

    Thanks in advance.

    Chandra

Answers

  • Friday, November 06, 2009 6:21 PMJamesChambers Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello Chandra,

    I would suggest a service debug approach like the following:

    Put a Thread.Sleep(15000) into the start of your service.  Start the service, then, in the IDE, attach your debugger to the service.  Have a breakpoint ready *after* the Thread.Sleep, and when the 15 seconds is up, you'll be able to debug.

    What does the batch file do?  If it's trying to access network resources or paths you might be getting a security error.  Have a look in your Event Viewer in Windows for more information.

    Hope this helps!

    Cheers,
    -jc

    Me, coding and stuff: Mr. James
  • Friday, November 06, 2009 6:58 PMPhilWilson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This is the kind of thing you get when you decide to do something in the OnStart type of service method and it crashes. Windows expects you to return and you didn't. This is most likely a case where you must handle any possible exceptions that your code might get. Services can report this type of error in an event log. There's also no reason you can't use a TraceListener to write to a text file to trace the flow of your code. 
    Phil Wilson

All Replies

  • Friday, November 06, 2009 6:21 PMJamesChambers Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello Chandra,

    I would suggest a service debug approach like the following:

    Put a Thread.Sleep(15000) into the start of your service.  Start the service, then, in the IDE, attach your debugger to the service.  Have a breakpoint ready *after* the Thread.Sleep, and when the 15 seconds is up, you'll be able to debug.

    What does the batch file do?  If it's trying to access network resources or paths you might be getting a security error.  Have a look in your Event Viewer in Windows for more information.

    Hope this helps!

    Cheers,
    -jc

    Me, coding and stuff: Mr. James
  • Friday, November 06, 2009 6:58 PMPhilWilson Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This is the kind of thing you get when you decide to do something in the OnStart type of service method and it crashes. Windows expects you to return and you didn't. This is most likely a case where you must handle any possible exceptions that your code might get. Services can report this type of error in an event log. There's also no reason you can't use a TraceListener to write to a text file to trace the flow of your code. 
    Phil Wilson
  • Friday, November 06, 2009 7:07 PMJeffWask Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What account is the service running under?  Does it have access to the batch file and any other filesystem objects it would need?