System.PlatformNotSupportedException:System.IO.Ports 目前仅在 Windows 上受支持。网络6

问题描述 投票:0回答:1

我正在尝试运行一些简单的代码来从 Linux 计算机上的串行端口读取数据,但我不断收到以下错误。

System.PlatformNotSupportedException: System.IO.Ports is currently only supported on Windows.

开发机使用安装在pop os上的Rider,项目是一个Net6控制台应用程序。

示例代码非常简单

using System.IO.Ports;

var s = new SerialPort("/dev/ttyUSB0");

任何帮助将不胜感激。

c# linux serial-port
1个回答
0
投票

我遇到了同样的问题,问题是 Visual Studio 建议使用最新版本的 NuGet 包 (9.x.x),即使我运行的是 .NET 6。我通过将包更改为 System.IO.Ports 6.0 来修复它。 0.

© www.soinside.com 2019 - 2024. All rights reserved.