C# 类型或命名空间名称';ManagementEventWatcher';找不到
为什么在以下代码中找不到类型或命名空间名称“ManagementEventWatcher”:C# 类型或命名空间名称';ManagementEventWatcher';找不到,c#,managementeventwatcher,C#,Managementeventwatcher,为什么在以下代码中找不到类型或命名空间名称“ManagementEventWatcher”: using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Diagnostics; using System.Management; class Program { public ManagementEventWatc
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没有这个方法,但是如何检查呢?你的主方法是静态的,但是你的mgmWtch变量不是。将其声明为静态。是否添加了引用以及使用?乙二醇
using System.Management;
这还不够。。您还需要添加对System.Management的引用。请重新表述问题。解释您正在努力解决的问题。找不到类型或命名空间名称“ManagementEventWatcher”是否缺少程序集引用?。查看.True的逐步方式,但问题总是她:/visual studio/.net的哪个版本是你的?BugFinder发现了一个“bug”。。。我只是忘了在项目中添加引用。但是谢谢你的帮助好的,你有例子吗?我刚开始学习c#我发现了\o/谢谢你的发现者