red eyes dev red eyes dev -4 years ago 154
C# Question

The type or namespace name 'ManagementEventWatcher' not found

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)
mgmtWtch = new System.Management
.ManagementEventWatcher("Select * From Win32_ProcessStartTrace");
mgmtWtch.EventArrived += new

I think my dll doesn't have this method, but how to check?

Answer Source

Have you added the reference as well as the using? eg

using System.Management;

is not enough.. you need to add the reference to System.Management too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download