Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are my System.Management.* classes?

Tags:

I just installed Visual Studio 2010 with .NET Framework 4.0 and C# and I can't find anything under the System.Management namespace except for System.Management.Instrumentation. All the online documentation at MSDN about WMI keeps telling me that I have to use classes such as System.Management.ManagementObjectSearcher or System.Management.ManagementScope but I don't see those classes.

What happened to those classes and how can I access them?

like image 827
Tom Avatar asked Nov 16 '10 12:11

Tom


People also ask

What is System management C#?

The System. Management namespace provides rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation.

How do you add references to System management?

Right click on the references in your project. Click Add Reference. Select the file (Project Root > Bin > System. Management.

Is System a class in C#?

In C#, the . NET Base Class Library(BCL) has a language-specific alias which is Object class with the fully qualified name as System.


2 Answers

You need to add a reference to System.Management.dll to your project.

You can see System.Management.Instrumentation without adding a reference to System.Management.dll because it is included in a different library (System.Core.dll, which is included as a reference automatically), but you cannot access the other types contained by that namespace without explicitly adding a reference to the System.Management.dll library.

like image 189
Cody Gray Avatar answered Jan 22 '23 02:01

Cody Gray


If you're using VS 2010, switch the project to .Net 4.0. Then click on Add References, you will now see System.Management in the list (and not only System.Management.Instrumentation). You can now use the System.Management classes.

I just had the same problem, and that fixed it!

like image 21
Rowan Avatar answered Jan 22 '23 03:01

Rowan