473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

program throws not found or not supported exception while using Managment Event

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
Sep 24 '07 #1
4 3961
Plater
7,872 Expert 4TB
Where does the exception occur? Like on what call?

What system are you trying to run it on?
I ran it fine on XP pro sp2, perhaps you must have sp2 for it to run?
Sep 24 '07 #2
i am running on windows xp professional sp2.
exception occur on statement
w.start();

Where does the exception occur? Like on what call?

What system are you trying to run it on?
I ran it fine on XP pro sp2, perhaps you must have sp2 for it to run?
Sep 24 '07 #3
Plater
7,872 Expert 4TB
Yeah, sorry, I see that now.

Well I looked up and saw:
.NET Framework Security
Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

So maybe you need to change permisions?
Sep 24 '07 #4
hbxtlhx
10
using (ManagementEventWatcher w = new ManagementEventWatcher(scope,q))
{
....
}


w is disposed!
make it global!

for example:

private ManagementEventWatcher w;

...

w=w ManagementEventWatcher(scope,q);
w....
Sep 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: surya | last post by:
Hi, I am using Assembly.LoadFrom within a web service to load assemblies from a web site. This web site is in the same machine where I am running the web service. The...
2
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol...
3
by: Luke | last post by:
I have a program that exits just fine when you close it manually, but throws an unhandled exception when I try to log off windows. It suggests I enable the JIT debugger, but when I compile the...
11
by: John S | last post by:
I'm writing a VB.Net 1.1 app that has to listen for messages coming to it via TCP/IP. When one arrives it it queued and then processed on a seperate thread while the main thread goes back to...
1
by: Martin | last post by:
Hi. I've found a few topics on this subject, but still not sure and decided to post mine. Here's my example: #include <iostream> using namespace std;
9
by: eclipsme | last post by:
Is it possible to take a VB program and run it from the Web? Any pointers/help would be very appreciated! Thanks, Harvey
4
by: AshishMishra16 | last post by:
HI friends, I am using the Flex to upload files to server. I m getting all the details about the file, but I m not able to upload it to Server. Here is the code i m using for both flex & for...
4
by: indrawati.yahya | last post by:
According to the FAQ, the best way to inform a class user of an error that occurs inside a constructor is to throw an exception. My question is, what happens when an object is instantiated using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.