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?
Have you added the reference as well as the using? eg
is not enough.. you need to add the reference to System.Management too.