I\'m getting the following error message:
The type or namespace name \'ManagementEventWatcher\' does not exist in the namespace \'System.Management\'
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.
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.