0

I need to work with serial ports, I had no problem in .net framework, but now porting on .NET 5 or above (wpf project), My.Computer.Ports.SerialPortNames is no more accessible. Here a simple sub that not work anymore.

Sub GetSerialPortNames()
        ' Show all available COM ports.
        For Each sp As String In My.Computer.Ports.SerialPortNames
            ListBox1.Items.Add(sp)
        Next
    End Sub

I added of course the import and the nuget package System.IO.Ports, but still get the exception BC30456'Computer' is not a member of 'myapp.My'. Any advice?

  • 3
    [Not available](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.devices.computer?view=windowsdesktop-7.0&viewFallbackFrom=net-5.0) in .NET5+. Use System.IO.Ports.SerialPort.GetPortNames() instead. – Hans Passant Apr 25 '23 at 11:01
  • The following may be of interest: https://stackoverflow.com/a/74895268/10024425 – Tu deschizi eu inchid Apr 25 '23 at 16:35

0 Answers0