title: ManagementObjectSearcher Get() Method throws an exception
body: <p>I'm attempting to run the following code:</p>
  
  <pre><code>ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_Processor");
  // This line throws the exception
  ManagementObjectCollection moc = mos.Get();
  </code></pre>
  
  <p>and I get the following excpetion: </p>
  
  <pre><code>System.Management.ManagementException: Invalid class 
     at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
     at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
     at LicenseCheckThingy.Form1.button1_Click(Object sender, EventArgs e)
     at System.Windows.Forms.Control.OnClick(EventArgs e)
     at System.Windows.Forms.Button.OnClick(EventArgs e)
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
     at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
     at System.Windows.Forms.Button.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  </code></pre>
  
  <p>For reference, the system I'm running on is a Windows XP SP 3 machine with .net 3.5 installed.  </p>
  
  <p>The user on this machine is configured as an administrator, howerver is not using the "Administrator" account.</p>
  
  <p>I created a sample project with basicaly just this code in it as a proof of error.  I know from adding simple show messages around the two lines that the line mos.Get() is the one that throws the error and exception text would seem to support that by virtue of the "ManagementObjectEnumerator.MoveNext()" in the stack trace.  Anyway, I'm at a loss as for what to even look for on the machine.</p>
  
  <p>Note, I've run this same code on over 50+ other machines (majority of them vista or windows 7) without issue, so it seems like it would be something specific to this box.  Suggestion/thought on what I could try?</p>
  
  <p>More information:
  So I've run the following code on the machine, this causes the same exceptions, but on the for loop declaration</p>
  
  <pre><code>MessageBox.Show("pre setup");  // displays correctly
  ManagementScope scope = new ManagementScope(@"\\" + Environment.MachineName + @"\root\cimv2");
  
  //connect to the machine 
  scope.Connect();
  
  MessageBox.Show("scope setup"); // displays correctly
  
  //use a SelectQuery to tell what we're searching in 
  SelectQuery searchQuery = new SelectQuery("SELECT * FROM Win32_Processor");
  //set the search up 
  ManagementObjectSearcher searcherObj = new ManagementObjectSearcher(scope, searchQuery);
  
  MessageBox.Show("search object setup"); // displays correctly
  
  //get the results into a collection 
  ManagementObjectCollection obj = searcherObj.Get();
  
  MessageBox.Show("got ManagementObjectCollection"); // displays correctly
  
  // next statement appears to cause Invalid class exception
  foreach ( ManagementObject mo in obj )
  {
     try
     {
        MessageBox.Show("looking for device id, cpu0"); // never shows up
  
        if ( string.Equals((string) mo["DeviceID"], "CPU0", StringComparison.InvariantCultureIgnoreCase) )
        {
           MessageBox.Show("processor ID: " + mo["ProcessorID"].ToString()); // never shows up
           break;
        }
     }
     catch ( Exception ex )
     {
        MessageBox.Show("Exception fetching processor id: " + ex.ToString()); // doesn't show
     }
  }
  </code></pre>
  
  <p>Other help??</p>
  
  <hr>
  
  <p>Wasn't able to get this one figured out, it seems as thought the web site that Johnv2020 recommended that there is a bug or issue in windows XP SP3 which does not allow me to get the processor ID.  For reference, the processor is acutally an i5 650 on this machine, and I've "worked around" this issue by wrapping the problem in a try catch and ignoring the processor ID in this case.   Special thanks to Johnv2020 for his help!</p>