我的程序在运行 open() 时给了我两个例外。
我已经做了很多搜索,但我无法解决它。有人可以帮助我,我对编程充满热情。所以,我不太清楚如何解决这些错误。
public void tempcpu()
{
myComputer = new Computer()
{
MainboardEnabled = true,
CPUEnabled = true,
RAMEnabled = true,
GPUEnabled = true,
FanControllerEnabled = true,
HDDEnabled = true
};
myComputer.Open();
float averange = 0;
foreach (var hardware in myComputer.Hardware)
{
if (hardware.HardwareType == HardwareType.CPU)
{
hardware.Update();
foreach (var sensor in (hardware.Sensors))enter code here
if (sensor.SensorType == SensorType.Temperature)
{if(sensor.Value!= null)
averange = averange + sensor.Value.Value;
}
}
cpu = averange / 5;
myComputer.Close();
}
}
例外: