Hi i'm using this method for get the mac address
public string GetMACAddress()
{
System.Management.ManagementClass mc = default(System.Management.ManagementClass);
ManagementObject mo = default(ManagementObject);
mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach (var mo in moc)
{
if (mo.Item("IPEnabled") == true)
{
return mo.Item("MacAddress").ToString();
}else
return null;
}
}
but i receive this error
Compiler Error Message: CS0234: The type or namespace name 'ManagementClass' does not exist in the namespace 'System.Management' (are you missing an assembly reference?)
What i have to do for fix it?
thanks
You need to add a reference to System.Management in your project.