3

I'm trying to run some simple code to read from serial port on a Linux machine but I keep getting the following error.

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

The development machine uses Rider installed on pop os and the project is a Net6 console app.

The sample code is really straight forward

using System.IO.Ports;

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

Any help will be appreciated.

  • 1
    Are you installing [System.IO.Ports 6.0.0](https://www.nuget.org/packages/System.IO.Ports/#supportedframeworks-body-tab) with the nuget package manager? [Create a C# Core.NET project using System.IO.Ports](https://stackoverflow.com/q/48545031/9014308), [How to download System.IO.Ports for C# \[duplicate\]](https://stackoverflow.com/q/68684487/9014308) – kunif Aug 21 '22 at 14:44
  • For example, there is an actual example that worked like this, so please try to find the cause patiently. [How to safely write to SerialPort in .NET 6 on Raspberry Pi](https://stackoverflow.com/q/71788941/9014308) It may be a good idea to create a new solution or project with the latest version of Visual Studio 2022. – kunif Aug 21 '22 at 17:33
  • Did you ever get a real solution to this? When running `dotnet run --os linux` it does work, but I do not know how to add that command to rider before starting – André Aug 18 '23 at 22:12

0 Answers0