Mark
Mark

Reputation: 71

Is the ManagementEventWatcher class no longer available in the System.Management namespace?

I'm getting the following error message:

The type or namespace name 'ManagementEventWatcher' does not exist in the namespace 'System.Management' (are you missing an assembly reference?)

I have included System.Management in my project references, yet the type cannot be found.

I have run Visual Studio as administrator and still get the same result. Has ManagementEventWatcher gone away?

Upvotes: 6

Views: 6646

Answers (2)

Suhaib Janjua
Suhaib Janjua

Reputation: 3574

You are probably missing the assembly reference to System.Management.dll. The using statement just brings names into scope, to save you typing the prefix: it doesn't actually add a DLL reference into the project.

If you have added the reference and didn't include using System.Management in your class then you gets this error message. Also if you just include using System.Management in your class and didn't include it's reference into your project, you will get a similar error message. You have to add the reference of System.Management.dll to your project just like I have shown below.


Go to the Solution Explorer, and expand your project, right click on the References folder/option and select Add References from the context menu. Now select the .Net tab and select the System.Management from the list and click OK.

In case if you have VS2010, VS2012, VS2013... Add the reference by right click on the References folder/option and select Add References from the context menu. Now select the Assemblies and then Framework tab and select the System.Management from the list and click OK.

enter image description here

Upvotes: 11

Christopher Painter
Christopher Painter

Reputation: 55591

Check that you've selected the correct CLR version for the DLL that you are adding. I looked in my C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1 folder and the System.Management.dll found in that folder still had the class. I added a reference and a using statement and I was able to construct it.

Upvotes: 0

Related Questions