0

I am trying to get a CPU ID Using managementobjectserarcher but I am getting an error of object reference not found instance of an object exception. The sample code has been written manually so may be some spelling mistake. but it is compiling properly.

please help me to get rid of this.

ManagementObjectSearcher obj = new ManagementObjectSearcher("Select * from Win32_processor")
foreach(ManagementObject ob in obj.Get())
Console.write(ob["ProcessorID"].toString());
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • The processor might not even support the [`CPUID`](http://stackoverflow.com/questions/1101772/win32-processoris-processorid-unique-for-all-computers) instruction. – tchelidze Jan 12 '16 at 07:53
  • "WMI property names are probably case-sensitive", So try [`ProcessorId`](http://stackoverflow.com/questions/6679208/how-to-get-processor-id-from-win32-processor) Instead of `ProcessorID` – tchelidze Jan 12 '16 at 07:55
  • @tchelidze I tried but its not working.. –  Jan 12 '16 at 09:33

1 Answers1

0

the code you write may work wrong! you should find the first not null item and work with that. in some cases like virtual machines and some multi core processors , it is possible that some item be null.

Behamooz
  • 1
  • 3