473,406 Members | 2,954 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,406 software developers and data experts.

WMI path and C# Question

Below is the code I am trying to use in a console application, each time I
run it I get an Management error Illegal Class error. I have traced the
error to the \"Win32_Process\" line, apparently the wmi path is incorrect.
Tried to run the app on both xp and vista with the same error. Could
someone suggest how I might correct this wmi path variable???

Thanks

Henry
++++++++++++++++++++++++++++++++++++++++++++++++++ +++

public static void WriteToEventLog()
{
WqlEventQuery DemoQuery = new
WqlEventQuery("_InstanceCreationEvent", new TimeSpan(0, 0, 1),
"TargetInstance isa \"Win32_Process\" ");

ManagementEventWatcher DemoWatcher = new
ManagementEventWatcher();
DemoWatcher.Query = DemoQuery;
DemoWatcher.Options.Timeout = new TimeSpan(0, 0, 30);

Console.WriteLine("Open an application to trigger an Event.");

ManagementBaseObject e = DemoWatcher.WaitForNextEvent();

EventLog DemoLog = new EventLog("Chap10Demo");
DemoLog.Source = "Chap10Demo";
String EventName =
((ManagementBaseObject)e["TargetInstance"])["Name"].ToString();
Console.WriteLine(EventName);
DemoLog.WriteEntry(EventName, EventLogEntryType.Information);

DemoWatcher.Stop();
}
+++++++++++++++++++++++++++++++Error follows
Unhandled Exception: System.Management.Man
at System.Management.ManagementExceptio
us errorCode)
at System.Management.ManagementEventWat
at ManagementEvents1.Program.WriteToEve
s1\ManagementEvents1\Program.cs:line 29
at ManagementEvents1.Program.Main(Strin
nts1\ManagementEvents1\Program.cs:line 14

--
~
Most good judgment comes from experience.
Most experience comes from bad judgment.
~I'm leaning towards bad judgment.~
Apr 6 '07 #1
0 1326

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
14
by: Thomas Heller | last post by:
I was trying to track down a bug in py2exe where the executable did not work when it is in a directory containing japanese characters. Then, I discovered that part of the problem is in the...
2
by: Teis Draiby | last post by:
(Using C#) Question 1: Is there an easy build-in support for determining wether a given file path is 1) A valid file path (Only legal characters) 2) The file exists 3) The path exists
20
by: Webdad | last post by:
Hi! I running my first year as industrial engineer (informatics) We have an assignment to do : .... create a playfield (matrix). Some places in that field are blocked, so you can't pass them....
2
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I...
2
by: Luis Arvayo | last post by:
I am compiling and executing c# code at runtime and I need to define in CompilerParameters.ReferencedAssemblies one of my own assemblies together with the standard System.dll u others. Example:...
11
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't...
3
by: schaf | last post by:
Hi ! I have determined, that Path.InvalidPathChars does not return an array with all invalid path characters. For instance the question mark (?) does not appear in the array, but it is not...
10
by: Elliot Peele | last post by:
Why does os.path.join('/foo', '/bar') return '/bar' rather than '/foo/bar'? That just seems rather counter intuitive. Elliot
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.