Trying to get some WMI objects in a UWP application. Running VS2015 on .net 4.6.
I'm getting errors for the ForEach and method calls stating "Reference to type 'Component' claims it is defined in 'System'" with error CS7069.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Management;
namespace SystemInfo
{
class wmiObject
{
static osDetails Program()
{
ManagementObjectCollection osDetailsCollection = getWMIObject("SELECT OSType, caption FROM Win32_OperatingSystem");
osDetails Details = new osDetails();
foreach (ManagementObject mo in osDetailsCollection)
{
Details.OSName = mo["Caption"].ToString();
}
osDetailsCollection = getWMIObject("SELECT Description, NumberOfLogicalProcessors, L3CacheSize from Win32_Processor");
foreach (ManagementObject mo in osDetailsCollection)
{
Details.NumberOfLogicalProcessors = mo["NumberOfLogicalProcessors"].ToString();
Details.L3CacheSize = mo["L3CacheSize"].ToString();
Details.Description = mo["Description"].ToString();
}
;
return Details;
}
static ManagementObjectCollection getWMIObject(string query)
{
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(query);
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
return osDetailsCollection;
}
class osDetails
{
public string Description;
public string OSName;
public string NumberOfLogicalProcessors;
public string L3CacheSize;
}
}
}
Errors
Severity Code Description Project File Line
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 41
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 18
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 20
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 26
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 28
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 29
Error CS7069 Reference to type 'Component' claims it is defined in 'System', but it could not be found SystemInfo C:\Users\Luke\Documents\GitHub\lgDns\lgDns\SystemInfo\SystemInfo\osDetails.cs 30
Any help would be appreciated.