G
Guest
I'm trying to execute this simple query:
ObjectQuery objectQuery = new ObjectQuery("Select * FROM Win32_Volume");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(objectQuery);
ManagementObjectCollection moc = searcher.Get();
try
{
foreach (ManagementObject volume in moc)
{
Console.WriteLine("Label = " + volume["Label"]);
}
}
catch (ManagementException e)
{
Console.WriteLine(e.Message);
}
But I get an ManagementException thrown in the foreach (not on the
Console.WriteLine that follows)
The message is simply "Invalid Class" which doesn't really tell me a whole
lot.
Looking around the web, I've found a couple of pieces of code that aren't
too different from this, but nothing to explain why I would be getting this
problem.
I'm running VS.NET 2003 on Win2K Professional.
Thanks for any help anyone can give.
ObjectQuery objectQuery = new ObjectQuery("Select * FROM Win32_Volume");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(objectQuery);
ManagementObjectCollection moc = searcher.Get();
try
{
foreach (ManagementObject volume in moc)
{
Console.WriteLine("Label = " + volume["Label"]);
}
}
catch (ManagementException e)
{
Console.WriteLine(e.Message);
}
But I get an ManagementException thrown in the foreach (not on the
Console.WriteLine that follows)
The message is simply "Invalid Class" which doesn't really tell me a whole
lot.
Looking around the web, I've found a couple of pieces of code that aren't
too different from this, but nothing to explain why I would be getting this
problem.
I'm running VS.NET 2003 on Win2K Professional.
Thanks for any help anyone can give.