本文介绍了类型或命名空间名称'的ServiceController“找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查在C#中的服务,我已经添加了 System.ServiceProcess.dll
I am trying to check a service in C#, I have added the System.ServiceProcess.dll
虽然我得到的错误:
错误2类型或命名空间名称'的ServiceController'找不到(是否缺少using指令或程序集引用?)D:\ APP \ Form1.cs的247 13应用
我的code是如下:
private void button13_Click(object sender, EventArgs e)
{
ServiceController sc = new ServiceController("Spooler");
if (sc.Status == ServiceControllerStatus.Running)
{
MessageBox.Show("The service is running.");
}
}
我也许需要一个使用的声明?
Do I perhaps need a "using" statement?
推荐答案
您需要添加一个引用到System.ServiceProcess.dll
You need to add a reference to the System.ServiceProcess.dll
在这之后,你就可以看到它在Visual Studio中,作为使用
语句,你可以添加到您的项目之一:
After that, you will be able to see it in Visual Studio, as one of the using
statements you can add to your project:
这篇关于类型或命名空间名称'的ServiceController“找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!