我试图在C#中检查一个服务,我添加了System.ServiceProcess.dll
虽然我收到错误:
Error 2 The type or namespace name ‘ServiceController’ could not be found (are you missing a using directive or an assembly reference?) D:\App\Form1.cs 247 13 App
我的代码如下:
private void button13_Click(object sender,EventArgs e) { ServiceController sc = new ServiceController("Spooler"); if (sc.Status == ServiceControllerStatus.Running) { MessageBox.Show("The service is running."); } }
我可能需要一个“使用”声明?