Tom
Tom

Reputation: 7223

Where are my System.Management.* classes?

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?

Upvotes: 23

Views: 58415

Answers (8)

sushil
sushil

Reputation: 321

I have netcore and net471 project.

I just downloaded the System.Management as official Microsoft nuget plugin.

Upvotes: 6

Oğuzhan SARI
Oğuzhan SARI

Reputation: 11

Find it on your computer > System.Management.dll

Find the .NetFrameWork version that fits your project.

Find the .NetFramework version in the folder name at the end of the search.

Copy the file.

Discard it in the "Bin" folder in your project.

Right click on the references in your project.

Click Add Reference.

Select the file (Project Root > Bin > System.Management.dll).

Project Clean and build.

Upvotes: 0

Rowan
Rowan

Reputation: 137

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!

Upvotes: 6

Jackson Pope
Jackson Pope

Reputation: 14640

You need to add a reference to System.Management.dll I think.

Upvotes: 1

Pieter van Ginkel
Pieter van Ginkel

Reputation: 29632

Have you added a reference to System.Management?

This may be due to having set the framework target to "Client Profile". Try switching to the normal "4.0 Framework".

Upvotes: 2

Cody Gray
Cody Gray

Reputation: 244782

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.

Upvotes: 38

Ani
Ani

Reputation: 113412

Add a reference to the System.Management.dll assembly. Both the System.Management.ManagementObjectSearcher and the System.Management.ManagementScope types are present in this assembly.

The reason you see the other types is because many types from the namespace System.Management.Instrumentation are present in System.Core.dll, which is normally automatically included by Visual Studio as a project reference.

Upvotes: 1

Moo-Juice
Moo-Juice

Reputation: 38825

Have you added a reference to System.Management.dll in your project?

Upvotes: 1

Related Questions