I was using some code to try to count the number of processors in .NET 2.0:
internal static int GetNumberOfProcessors()
List<string> list = new List<string>();
ManagementClass mgmt = new ManagementClass("Win32_Processor");
foreach (ManagementObject obj in mgmt.GetInstances())
string item = obj.Properties["SocketDesignation"].Value.ToString();
[ManagementException: Access denied ]
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) +377984
System.Management.ManagementScope.InitializeGuts(Object o) +654
System.Management.ManagementObject.Initialize(Boolean getObject) +492
System.Management.ManagementClass.GetInstances(EnumerationOptions options) +122
Ok, I hate answering my own question, but I found this: http://support.microsoft.com/kb/317012 and it does seem to work.
You have to specifically modify your CIMV2 permissions, and I had to do it for the specific user, not ASPNET. Once this is on, you can use the System.Management code to count processors etc.
I really don't like how obscure this was. Microsoft needs to update those exceptions. When the System.Management class fails like that it should give detailed info on which permissions need activated for the code to work.