我在获取MAC地址是出现"未处理COMException"异常是怎么回事,下面是我的代码:string mac = null;
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
ManagementObjectCollection queryCollection = query.Get();
foreach (ManagementObject mo in queryCollection)
{
if (mo["IPEnabled"].ToString() == "True")
mac = mo["MacAddress"].ToString();
}
return (mac);
异常出现在循环读取的地方,好像是queryCollection.count引发的异常,该如何解决呀?
当年话下