类型或命名空间名称“ManagementEventWatcher”未找到
为什么我在以下代码中得到未找到类型或命名空间名称“ManagementEventWatcher”:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Management;
class Program {
public ManagementEventWatcher mgmtWtch;
static void Main(string[] args)
{
InitializeComponent();
mgmtWtch = new System.Management
.ManagementEventWatcher("Select * From Win32_ProcessStartTrace");
mgmtWtch.EventArrived += new
System.Management.EventArrivedEventHandler(mgmtWtch_EventArrived);
mgmtWtch.Start();
}
}
我认为我的 dll 没有此方法,但如何检查?
Why do I get The type or namespace name 'ManagementEventWatcher' not found in the following code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Management;
class Program {
public ManagementEventWatcher mgmtWtch;
static void Main(string[] args)
{
InitializeComponent();
mgmtWtch = new System.Management
.ManagementEventWatcher("Select * From Win32_ProcessStartTrace");
mgmtWtch.EventArrived += new
System.Management.EventArrivedEventHandler(mgmtWtch_EventArrived);
mgmtWtch.Start();
}
}
I think my dll doesn't have this method, but how to check?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您添加了参考以及使用吗?例如
还不够..您还需要添加对 System.Management 的引用。
Have you added the reference as well as the using? eg
is not enough.. you need to add the reference to System.Management too.
您的 Main 方法是静态的,但您的 mgmWtch 变量不是。将其声明为静态。
Your Main method is static, but your mgmWtch variable is not. Declare it as as static.