hello
while running program that use system.manageme nt 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.EventClassNam e = "RegistryTreeCh angeEvent";
q.Condition = @"Hive='HKEY_LO CAL_MACHINE' and RootPath='Softw are\\Policies'" ;
using (ManagementEven tWatcher w = new ManagementEvent Watcher(scope,q ))
{
w.EventArrived += new EventArrivedEve ntHandler(EvLog EventArrived);
w.Start(); //exception throws on this line
Console.ReadLin e(); // Block this thread for test purposes only....
w.Stop();
}
}
static void EvLogEventArriv ed(object sender, EventArrivedEve ntArgs e)
{
//Get the Event object and display it
foreach (PropertyData pd in e.NewEvent.Prop erties)
{
//if (pd.Name.ToLowe r() == "rootpath")
Console.WriteLi ne("{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
while running program that use system.manageme nt 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.EventClassNam e = "RegistryTreeCh angeEvent";
q.Condition = @"Hive='HKEY_LO CAL_MACHINE' and RootPath='Softw are\\Policies'" ;
using (ManagementEven tWatcher w = new ManagementEvent Watcher(scope,q ))
{
w.EventArrived += new EventArrivedEve ntHandler(EvLog EventArrived);
w.Start(); //exception throws on this line
Console.ReadLin e(); // Block this thread for test purposes only....
w.Stop();
}
}
static void EvLogEventArriv ed(object sender, EventArrivedEve ntArgs e)
{
//Get the Event object and display it
foreach (PropertyData pd in e.NewEvent.Prop erties)
{
//if (pd.Name.ToLowe r() == "rootpath")
Console.WriteLi ne("{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
Comment