I'm not able to call some functions of the System.Management class; for my program.
I've tried to using System.Management;
or System.Management.ManagementObject
but it also does not work.
Code:
static string getid()
{
string cpuInfo = string.Empty;
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties["processorID"].Value.ToString();
break;
}
string drive = "C";
ManagementObject dsk = new ManagementObject(
@"win32_logicaldisk.deviceid=""" + drive + @":""");
dsk.Get();
string volumeSerial = dsk["VolumeSerialNumber"].ToString();
string uniqueId = cpuInfo + volumeSerial;
return uniqueId;
}
Error:
Severity Code Description Project File Line Suppression State Error CS0246 The name of the "ManagementObjectCollection" type or namespace can not be found (is it missing a using directive or an assembly reference?) PurePaste C: \ Users \ gabri \ Desktop \ Pedrin Looks at 3.0 \ PurePaste \ Student \ login. cs 73 Active