title: System.Management - Object reference not set to an instance of an object
body: <pre><code>private string Find(string key)
      {
          string result = null;
          try
          {
              ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PnPEntity");
              foreach (ManagementObject queryObj in searcher.Get())
                  if (queryObj["Caption"].ToString().Contains(key))
                  {
                      result = queryObj["Caption"].ToString();
                      break;
                  }
          }
          catch (Exception ex)
          {                                                                
                MessageBox.Show(ex.Message);                
          }
          return result;
      }
  </code></pre>
  
  <p>I Add Reference: System.Management to use this function to find a divice. It work it works on <strong>Window 7</strong>, but on <strong>Window XP</strong> have a error: <strong>object reference not set to an instance of an object</strong></p>
  
  <p>How to solve this error?</p>