none
Start a window service from a WCF service RRS feed

  • Question

  • I am trying to start a window service using service controller, from a WCF service hosted on the same machine. But it is giving an exception.

    CODE-->

    using (ServiceController serviceController = new ServiceController(serviceName, machineName))
                {
                    serviceController.Start();
                }

    Exception-->

    System.InvalidOperationException: Cannot open AppCheckOut_TakeLatestCode service on computer '...'. ---> System.ComponentModel.Win32Exception: Access is denied
       --- End of inner exception stack trace ---
       at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess)
       at System.ServiceProcess.ServiceController.Start(String[] args)
       at System.ServiceProcess.ServiceController.Start()
       at TTX.Application.AppCheckOut.SchedulingService.SchedulingService.TakeLatestCode()

    Both the services are running with the same user account. Can we start a Window service from WCF service like this. Please help

    Wednesday, January 23, 2013 8:01 AM

Answers