Why is "Hardware.Sensors" not working - LibreHardwareMonitor C#

171 Views Asked by At

I am new to utilising LibreHardwareMonitor and was wondering why the following line of code is not working.

foreach (ISensor sensor in Hardware.Sensors) { ... }

The error states that:

An object reference is required for the non-static field, method, or property 'Hardware.Sensors'

I am unsure how to go about fixing this, as I must use this tool to gather the temperature information on the hardware within the PC.

private void tabTemps_Enter(object sender, EventArgs e)
   {
      Computer c = new Computer
      {
      IsCpuEnabled = true,
      IsGpuEnabled = true,
      IsMemoryEnabled = true,
      IsMotherboardEnabled = true,
      IsControllerEnabled = true,
      IsNetworkEnabled = true,
      IsStorageEnabled = true
   };

   c.Open();
            
   foreach (ISensor sensor in Hardware.Sensors)
   {
      rtbTemps.AppendText($"Sensor: {sensor.Name}, Value: {sensor.Value}");
   }
}

Thanks,
nozzy

0

There are 0 best solutions below