使用ManagementClass获取cup,硬盘等信息,极少电脑会出问题,但是还是碰到了,提示
System.IO.FileNotFoundException: 
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
为什么会报错呢?

解决方案 »

  1.   

    代码是这个
    string cpuInfo = " ";
                using (ManagementClass cimobject = new ManagementClass("Win32_Processor"))
                {
                    ManagementObjectCollection moc = cimobject.GetInstances();                foreach (ManagementObject mo in moc)
                    {
                        cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
                        mo.Dispose();
                    }
                }
    在我电脑上没报错,是在客户电脑上出现的,是.net framework弹出来的框