hello
while running program that use system.management namespace and holds management event the exception throws "not found" and some time "not supported" unhandled management exception on management event start() method, i am using windows xp professional sp2, the sample code is
class Program
{
public static void Main(string[] args)
{
ManagementScope scope = new ManagementScope("root\\default");
WqlEventQuery q = new WqlEventQuery();
q.EventClassName = "RegistryTreeChangeEvent";
q.Condition = @"Hive='HKEY_LOCAL_MACHINE' and RootPath='Software\\Policies'";
using (ManagementEventWatcher w = new ManagementEventWatcher(scope,q))
{
w.EventArrived += new EventArrivedEventHandler(EvLogEventArrived);
w.Start(); //exception throws on this line
Console.ReadLine(); // Block this thread for test purposes only....
w.Stop();
}
}
static void EvLogEventArrived(object sender, EventArrivedEventArgs e)
{
//Get the Event object and display it
foreach (PropertyData pd in e.NewEvent.Properties)
{
//if (pd.Name.ToLower() == "rootpath")
Console.WriteLine("{0} = {1}", pd.Name, pd.Value);
}
}
}
these types of program running correctly when i am using xp home sp2, but when change operating system these program fail to run..
plz help me if u have any idea i am very tense bcoz these exception is throw in my final project.
thanks aton
bye