I try to obtain some system information with several classes from System.Management namespace but any attempt to use ManagementObjectSearcher or ManagementObjectCollection collection items results in FileNotFoundException.
Below I present the problematic piece of code:
public static string GetProcessorID() {
var processorID = "";
var query = "SELECT ProcessorId FROM Win32_Processor";
var oManagementObjectSearcher = new ManagementObjectSearcher(query);
foreach (var oManagementObject in oManagementObjectSearcher.Get()) {
processorID = (string)oManagementObject["ProcessorId"];
break;
}
return processorID;
}
Exception is thrown in 'foreach' line, when trying to obtain next item from the collection.
It is observed on machine with windows xp professional sp3, with visual studio 2008 professional. I suppose that it can be something with my cpu, which is intel dual core - the same program on other machine with similar environment works perfect. The main difference between those machines is cpu.
Other parameters like MACAddress and SystemDrive provides the same problem, which suggests that it might be rather software issue (WMI?)
Very similar problem is described here -> http://news.softpedia.com/news/XP-SP3-Win32-Processor-Class-Labels-Intel-Core-2-Duo-CPUs-Incorectly-90201.shtml but the solution did not solved it.
Any ideas? Thanks in advance.
Dawid
I know my answer is a bit late, but because it's the first hit on google when i searched my error i guess i put a link to the topic solving it for me.
System.Management.ManagementException: Not found
Basicly what you have to do is resolve your error's with WMI.