1
I am unable to call some functions of the System.Management class; for my program.
I’ve tried to put using System.Management;
or System.Management.ManagementObject
but it also doesn’t 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:
Gravity Code Description Project File Line Deletion State CS0246 The type or namespace name "Managementobjectcollection" cannot be found (is a using directive or an Assembly reference missing?) Purepaste C: Users Gabri Desktop Pedrin Mira certain 3.0 Purepaste Student login.Cs 73 Active
Using
System.Management.ManagementObjectCollection
works?– Jéf Bueno
no, it doesn’t work.
– Francisco