The type or namespace name ‘ServiceController’ could not be found

Posted on July 6, 2018 by Suresh Kamrushi in C#, Windows

May times you need to add namespaces to your application, here I sharing how you can add “System.ServiceProcess” required to incorporate windows services to your application.

Follow the below steps add references:
1) Right click on solution explore and click on add reff
Add Reference
2( go to Assembly => Framework and look for “System.ServiceProcess” and enable it.
Click OK to enable it.

3) Now add belowline at the top:

using System.ServiceProcess;

4) Add the code below:

ServiceController svcController = new ServiceController("Test Windows Service");

if (svcController != null)
        //svcController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
  Comments or questions are welcome  
Tagged as ,