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:\"");
Right click on the references in your project. Click Add Reference. Select the file (Project Root > Bin > System. Management.
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.
Have you added a reference to the System.Management assembly?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With