如何在Silverlight应用程序中获取所有串口com

时间:2013-02-28 05:20:15

标签: asp.net silverlight-5.0

我有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注册的对象。

0 个答案:

没有答案