Many 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
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) { try { //svcController.Stop(); //svcController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10)); svcController.Start(); } catch { } }