我正在尝试在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.");
}
}
我是不是需要一个 "using" 语句?