System.IO.Ports.SerialPort.GetSerialPorts()抛出异常 [英] System.IO.Ports.SerialPort.GetSerialPorts() throwing exception

查看:662
本文介绍了System.IO.Ports.SerialPort.GetSerialPorts()抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在调用GetSerialPorts()方法时遇到异常。

Hi I am getting exception when I call GetSerialPorts() method.

Exception Messagge:没有更多数据可用。

Exception Messagge: No more data is available.

堆栈跟踪:

at Microsoft.Win32.RegistryKey.Win32Error(int32 errorCode,string str)

at Microsoft.Win32.RegistryKey.Win32Error(int32 errorCode, string str)

at Microsoft.Win32.RegistryKey.GetValueNames()

at Microsoft.Win32.RegistryKey.GetValueNames()

在System.IO.Ports.SerialPort.GetPortNames()

at System.IO.Ports.SerialPort.GetPortNames()

................ ..........................................

..........................................................

任何想法。请帮帮我。

推荐答案

也许您应该向我们展示您正在使用的代码。

Perhaps you should show us the code you are using.

以下是否适用于您?

      string [] ports = SerialPort.GetPortNames();
      foreach( string port in ports )
      {
        Console.WriteLine( port );
      }


Andy

Andy


这篇关于System.IO.Ports.SerialPort.GetSerialPorts()抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆