Windows Service installed. But start, stop buttons disabled
I created windows service. Installed with Installutil.exe success, but when i press start button appears progress bar "starting", then it stopped at 50 percent. I have to cancel. After cancel service works perfect, but start, stop and pasue commands disabled. If i want to stop service, i have to uninstall service. What can be reason ?
static void Main()
ServicesToRun = new ServiceBase
// SCM requests service start using its own thread.
// This method must complete within 10 seconds of it
// starting. Otherwise the SCM diagnoses a hang.
protected override void OnStart(string args)
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.UnhandledExceptionFilter);
this.ThreadController = new Thread(new ThreadStart(ControllerThreadRunning));
this.ThreadController.Name = THREAD_NAME_CONTROLLER;
This is the controller thread:
// Invoked when the controller thread starts.
private void ControllerThreadRunning()
// And we're on our way.
while ( !this.ServiceStopRequested )
// Start real work and then block until that finishes or crashes.
var realWork = this.LaunchWorkAsync();
// If SCM didn't request a service stop, the assumption is that
// the real work crashed and needs to be restarted.
if ( !this.ServiceStopRequested )
this.PauseControllerThread("Pause before restarting work cycle.", this.RestartDelay);
// This service will now stop.
This asynchronously launches the service's real work:
// This method handles all ceremony around the real work of this service.
private async Task LaunchWorkAsync()
// Setup progress reporting.
Asked in February 2016Viewed 3,744 timesVoted 12Answered 1 times