I'm trying to build a relatively simple console program in Visual Studio Code. Using the 32feet.net package. the code is as follows
using System;
using System.Management;
const string Win32_SerialPort ="Win32_SerialPort";
SelectQuery q =new SelectQuery(Win32_SerialPort);
ManagementObjectSearcher s =new ManagementObjectSearcher(q);
foreach(object cur in s.Get())
{
ManagementObject mo = (ManagementObject)cur;
object id = mo.GetPropertyValue("DeviceID");
object pnpId = mo.GetPropertyValue("PNPDeviceID");
console.WriteLine("DeviceID: {0} ", id);
console.WriteLine("PNPDeviceID: {0} ", pnpId);
console.WriteLine("");
}
and I get the error error CS0234: The type or namespace name 'SelectQuery' does not exist in the namespace 'System.Management' (are you missing an assembly reference?)
But when I search on SelectQuery it shows up as within the namespace System.Management and if I type in the code window System.Management. Visual Studio Code recognizes SystemQuery as one of the types. What am I missing???
I expected the code to build. But got the error mentioned above.