我有vs 2012,我想要2获取计算机的所有串口, 为此,我编写了代码
// com = AutomationFactory.CreateObject("ComInterOp_SeeLevel828_Utility");
com = AutomationFactory.GetObject("InteropComObjects.IO.Ports.SerialPort");
dynamic count = com.GetDeviceCount();
StringBuilder sb = new StringBuilder();
List<dynamic> devices = new List<dynamic>();
for (int i = 1; i <= 9; i++)
{
devices.Add("COM" + i);
}
for (int i = 0; i < count; i++)
{
devices.Add(com.GetDevice(i));
}
cmdSerial.ItemsSource = devices;
但我在行中出现错误
com = AutomationFactory.GetObject("InteropComObjects.IO.Ports.SerialPort");
as未找到为指定的ProgID注册的对象。