I created a C# 4.0 Console application. The target framework is .Net Framework 4 Client profile. I want to count the number of cores in my cpu. To do this I created the following class:
internal class MultiThreading
{
public int GetNumberOfCores()
{
var coreCount = 0;
foreach (var item in new System.Management.ManagementObjectSearcher("Select * from Win32_Processor").Get())
coreCount += int.Parse(item["NumberOfCores"].ToString());
return coreCount;
}
}
For this code to work, it needs a reference to System.Management. To do this in the solution explorer I right clicked my project references->Add reference. A dialog window opens and allows me to select System.Management version 4.0.0.0. The dialog window shows that I am using the 4.0 Framework. So far so good. I click "Add" and I get the following message:
"System.Management, Version 4.0.0.0, Culture=neutral, PublicKeyToken = b034543655555" is incompatible with .Net Framework 4 Client Profile In order to add it you should change >the project's target to a compatible framework first.
As a sanity check I went here: http://msdn.microsoft.com/en-us/library/system.management.managementobjectsearcher.aspx
...and msdn clearly states that System.Management 4.0.0.0 is compatible with .Net Framework 4 Client Profile.
Can anyone assist?