Click here to Skip to main content
15,887,333 members
Home / Discussions / C#
   

C#

 
AnswerRe: hi Pin
Luc Pattyn30-Apr-11 10:14
sitebuilderLuc Pattyn30-Apr-11 10:14 
GeneralRe: hi Pin
stranger8030-Apr-11 10:30
stranger8030-Apr-11 10:30 
QuestionHow do I take the content from a javascript variable, and paste it into a c# variable? Pin
_Q12_30-Apr-11 6:59
_Q12_30-Apr-11 6:59 
AnswerRe: How do I take the content from a javascript variable, and paste it into a c# variable? Pin
Dave Kreskowiak30-Apr-11 10:04
mveDave Kreskowiak30-Apr-11 10:04 
AnswerRe: How do I take the content from a javascript variable, and paste it into a c# variable? Pin
Eddy Vluggen30-Apr-11 22:13
professionalEddy Vluggen30-Apr-11 22:13 
GeneralRe: How do I take the content from a javascript variable, and paste it into a c# variable? Pin
_Q12_5-May-11 8:26
_Q12_5-May-11 8:26 
GeneralRe: How do I take the content from a javascript variable, and paste it into a c# variable? Pin
Eddy Vluggen5-May-11 9:21
professionalEddy Vluggen5-May-11 9:21 
QuestionUsings for "ManagementClass" in Visual C# 2010 Pin
rms12330-Apr-11 2:28
professionalrms12330-Apr-11 2:28 
Hello!

I'm using this code to detect the cpu temperature.
But I get the error: "The type or namespace name 'ManagementClass' could not be found (are you missing a using directive or an assembly reference?)", But I think I use all usings I need.

I'm using visual C# 2010

This is my code:

using System;
using System.Windows.Forms;
using System.Management;

namespace Heater
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            ManagementClass processClass = new ManagementClass(@"root\WMI:MSAcpi_ThermalZoneTemperature");

            foreach (ManagementObject service in processClass.GetInstances())
            {
                MessageBox.Show("CPU Temperature: " + service.GetPropertyValue("CurrentTemperature"));
            }
        }


        static decimal ConvertToCelsius(string reading)
        {

            return (decimal.Parse(reading) / 10 - 273.15m);

        }
    }
}


I want the output to label1, but that's not important now, because the script isn't working.

If I remove all unused usings, system.management is gone too!

Thanks in advance!

PS: sorry for my worse English :/
AnswerRe: Usings for "ManagementClass" in Visual C# 2010 Pin
Philippe Mori30-Apr-11 2:39
Philippe Mori30-Apr-11 2:39 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
rms12330-Apr-11 2:45
professionalrms12330-Apr-11 2:45 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
Philippe Mori30-Apr-11 2:56
Philippe Mori30-Apr-11 2:56 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
Philippe Mori30-Apr-11 3:02
Philippe Mori30-Apr-11 3:02 
AnswerRe: Usings for "ManagementClass" in Visual C# 2010 [modified some more] Pin
Luc Pattyn30-Apr-11 2:46
sitebuilderLuc Pattyn30-Apr-11 2:46 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
rms12330-Apr-11 2:54
professionalrms12330-Apr-11 2:54 
AnswerRe: Usings for "ManagementClass" in Visual C# 2010 Pin
Luc Pattyn30-Apr-11 2:59
sitebuilderLuc Pattyn30-Apr-11 2:59 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
rms12330-Apr-11 3:20
professionalrms12330-Apr-11 3:20 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
PIEBALDconsult30-Apr-11 3:37
mvePIEBALDconsult30-Apr-11 3:37 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
Luc Pattyn30-Apr-11 4:08
sitebuilderLuc Pattyn30-Apr-11 4:08 
GeneralRe: Usings for "ManagementClass" in Visual C# 2010 Pin
PIEBALDconsult30-Apr-11 4:59
mvePIEBALDconsult30-Apr-11 4:59 
AnswerRe: Usings for "ManagementClass" in Visual C# 2010 Pin
Luc Pattyn30-Apr-11 5:09
sitebuilderLuc Pattyn30-Apr-11 5:09 
QuestionProgram With Multi language support Pin
Arunkumar.Koloth29-Apr-11 17:32
Arunkumar.Koloth29-Apr-11 17:32 
AnswerRe: Program With Multi language support Pin
OriginalGriff29-Apr-11 20:54
mveOriginalGriff29-Apr-11 20:54 
AnswerRe: Program With Multi language support Pin
PIEBALDconsult1-May-11 3:13
mvePIEBALDconsult1-May-11 3:13 
GeneralRe: Program With Multi language support Pin
Arunkumar.Koloth1-May-11 6:31
Arunkumar.Koloth1-May-11 6:31 
GeneralRe: Program With Multi language support Pin
PIEBALDconsult1-May-11 17:28
mvePIEBALDconsult1-May-11 17:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.