Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can you debug this error? The <service name> service could not be started. The service did not report an error

The service could not be started. The service did not report an error.

I encounter this error whenever I install a windows service project in the command line. It's true that there's an error in my code, but how can I find that error with this kind of error message?

like image 434
Lance Avatar asked Jul 30 '09 08:07

Lance


2 Answers

There is an exception in your service's OnStart() method, add

 try{...} 
 catch(Exception ex)
 {
     //write to file ex.ToString();
 }

and log your exception to file

like image 193
Arsen Mkrtchyan Avatar answered Oct 14 '22 20:10

Arsen Mkrtchyan


Add error handling block (catching UnhandledException or just try/catch block around suspected code) and log it (I use either Trace or Debug - you can view that messages with DebugView).

In order to give idea to Service Manager that there is error (just to help user) you can:

service.ExitCode = 1064; //ERROR_EXCEPTION_IN_SERVICE - just example

Where "service" is your Service's object.

like image 31
Josip Medved Avatar answered Oct 14 '22 20:10

Josip Medved