473,725 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(" _InstanceCreati onEvent", new TimeSpan(0, 0, 1),
"TargetInst ance isa \"Win32_Process \" ");

ManagementEvent Watcher DemoWatcher = new
ManagementEvent Watcher();
DemoWatcher.Que ry = DemoQuery;
DemoWatcher.Opt ions.Timeout = new TimeSpan(0, 0, 30);

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

ManagementBaseO bject e = DemoWatcher.Wai tForNextEvent() ;

EventLog DemoLog = new EventLog("Chap1 0Demo");
DemoLog.Source = "Chap10Demo ";
String EventName =
((ManagementBas eObject)e["TargetInstance "])["Name"].ToString();
Console.WriteLi ne(EventName);
DemoLog.WriteEn try(EventName, EventLogEntryTy pe.Information) ;

DemoWatcher.Sto p();
}
+++++++++++++++ +++++++++++++++ +Error follows
Unhandled Exception: System.Manageme nt.Man
at System.Manageme nt.ManagementEx ceptio
us errorCode)
at System.Manageme nt.ManagementEv entWat
at ManagementEvent s1.Program.Writ eToEve
s1\ManagementEv ents1\Program.c s:line 29
at ManagementEvent s1.Program.Main (Strin
nts1\Management Events1\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 1345

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

Similar topics

31
3920
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 in the os module got objectified properly (or at least with some semblance of OO propriety!) In the issues section:
14
2636
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 zipimporter that py2exe uses, and finally I found that it didn't even work in Python itself. If the entry in sys.path contains normal western characters, umlauts for example, it works fine. But when I copied some japanese characters from a random...
2
1729
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
17038
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. The others are free to go over ... (I already found that part) -> http://users.pandora.be/hebbrecht/jochen/c++/test.cpp
2
3875
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 have a mapping of .* to the aspnet_isapi.dll. And my web.config has an entry thusly: <add verb="*" path="*" type="HandlerClass, HandlerAssembly" /> And this is working just fine thus far. The handler gets all the requests and works like a...
2
10956
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: // compiler options System.CodeDom.Compiler.CompilerParameters options = new System.CodeDom.Compiler.CompilerParameters(); options.GenerateExecutable = false; // result is a dll
11
2450
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 find a file when extra path information is added. Is there a switch in ASP or something I can change that'll get it to work? Thanks!
3
5988
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 possible to create a folder with a question mark (?). How can I get the whole range of invalid path characters ? Or is it the best way, to create a folder and using try/catch ? Regards
10
11791
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
11510
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 file. each control has a border with another style, and each border has a unique path inside of it. I need to dynamically add these content controls using c# at runtime and am having trouble referencing the styles and adding the path into the...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.