Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ManagementObject Class not showing up in System.Management namespace

Tags:

c#

.net

I'm trying to write some WMI in my windows form and the ManagementObject is givin me the

"The type or namespace name 'ManagementObject' could not be found" Error

Here is my un-complete code:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Threading; using System.Security.Policy; using System.Management; using System.Management.Instrumentation;   namespace ConsoleApplication2 {     class Program     {         static void Main(string[] args)         {               ManagementObject disk = new ManagementObject("Win32_LogicalDisk.DeviceID=\"C:\""); 
like image 726
Drew Avatar asked Nov 30 '10 14:11

Drew


People also ask

How do I add a reference to system management DLL?

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


2 Answers

Right-click References on the right and manually add System.Management. Even though I included it in the using statement I still had to do this. Once I did, all worked fine.

like image 69
anon Avatar answered Oct 03 '22 15:10

anon


Have you added a reference to the System.Management assembly?

like image 21
Paul Nearney Avatar answered Oct 03 '22 14:10

Paul Nearney