C# – Cannot start the windows service

cnetwcfwindows-services

I created a WCF library, then I wrote a WCF service which can create or open a file and writes "hello world" in that file. Then I added a new project to a Windows service. In that Windows service onstart() method I call the WCF service, then I build and installed the service using installutil. The service was installed successfully, while i am starting the service in services.msc, it shows the following error

the service on local computer started and then stopped some services
stopped automatically. if they have no work to do, for example the
performance logs, and alerts.

Why am i getting this error, how can I resolve it?

Best Answer

(i)Clear the Application Log.

(ii)Use the debugger and trace the execution of the OnStart() method.

if these does not work,

1) Click Run Command from start button

2) Enter Services.msc then click OK,you will get all the services in your computer.

3) Select your service and right click on the service and select Properties

4) Goto Logon Properties a select Local System Account then click OK