title: System.Management access denied
body: <p>I was using some code to try to count the number of processors in .NET 2.0:</p>
  
  <pre><code>internal static int GetNumberOfProcessors()
  {
      List&lt;string&gt; list = new List&lt;string&gt;();
      ManagementClass mgmt = new ManagementClass("Win32_Processor");
      foreach (ManagementObject obj in mgmt.GetInstances())
      {
          string item = obj.Properties["SocketDesignation"].Value.ToString();
          if (!list.Contains(item))
          {
              list.Add(item);
          }
      }
      return list.Count;
  }
  </code></pre>
  
  <p>and it blew up like this:</p>
  
  <pre><code>[ManagementException: Access denied ]
     System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) +377984
     System.Management.ManagementScope.InitializeGuts(Object o) +654
     System.Management.ManagementScope.Initialize() +162
     System.Management.ManagementObject.Initialize(Boolean getObject) +492
     System.Management.ManagementClass.GetInstances(EnumerationOptions options) +122
     System.Management.ManagementClass.GetInstances() +6
  </code></pre>
  
  <p>This code runs fine locally on cassini, but blows up on our beta server. Anyone have any idea what to do about this?</p>