小编Mik*_*ike的帖子

找不到类型或命名空间名称"ServiceController"

我正在尝试用C#检查服务,我已添加了 System.ServiceProcess.dll

虽然我收到错误:

错误2找不到类型或命名空间名称'ServiceController'(您是否缺少using指令或程序集引用?)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.");
    }
}
Run Code Online (Sandbox Code Playgroud)

我是否需要"使用"声明?

.net c# windows

12
推荐指数
2
解决办法
2万
查看次数

如何将文本文件中的文本插入C#中的Label控件

有人可以演示如何将文本文件中的文本,例如test.txt插入到可视化C#表单上的Label控件中

.net c# file winforms

7
推荐指数
2
解决办法
3852
查看次数

标签 统计

.net ×2

c# ×2

file ×1

windows ×1

winforms ×1