My code:
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO.Ports;
using System.Windows.Forms;
namespace MyProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
foreach (object portName in SerialPort.GetPortNames())
{
comboBox1.Items.Add(portName);
}
}
Everything works fine apart from the error: The name 'SerialPort' does not exist in the current context
I don't understand because I have using System.IO.Ports; .NET 6.0 Windows Forms C#