In any language, visual studio 2022 does not recognize terms like "Serial Port" and "handshake"

Chetty 31 Reputation points
2022-07-07T18:40:53.247+00:00

Downloaded several codes with languages from Visual Basic to C# for Serial Communication but visual studio 2022 does not recognize terms like "Serial Port" or "Handshake" even with the references that allegedly were previously used by the authors. Is there a new reference? .Net 6.0 evidently has removed such information.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,604 questions
{count} votes

10 answers

Sort by: Most helpful
  1. Chetty 31 Reputation points
    2022-07-13T10:46:47.393+00:00

    Please explain how you got "System.IO.Port" into the code? I thought i tried everything possible.

    1 person found this answer helpful.

  2. Chetty 31 Reputation points
    2022-07-13T11:51:12.24+00:00

    In Visual Studio c# there is under the tool bar a feature NuGet, within this item there is a call for a source and name to get what we are after. On first use these items are filled in automatically and did not work for me. After numerous efforts at trying different names and sources, no success. Either I am using the wrong tool or what ever but no one yet has explained my failures.

    1 person found this answer helpful.
    0 comments No comments

  3. Chetty 31 Reputation points
    2022-07-08T10:54:23.717+00:00

    Here is an example in C#

    using System;
    using System.IO.Ports;

    class PortDataReceived
    {
    public static void Main()
    {
    SerialPort mySerialPort = new SerialPort("COM4");

        mySerialPort.BaudRate = 9600;  
        mySerialPort.Parity = Parity.None;  
        mySerialPort.StopBits = StopBits.One;  
        mySerialPort.DataBits = 8;  
        mySerialPort.Handshake = Handshake.None;  
        mySerialPort.RtsEnable = true;  
    
        mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);  
    
        mySerialPort.Open();  
    
        Console.WriteLine("Press any key to continue...");  
        Console.WriteLine();  
        Console.ReadKey();  
        mySerialPort.Close();  
    }  
    
    private static void DataReceivedHandler(  
                        object sender,  
                        SerialDataReceivedEventArgs e)  
    {  
        SerialPort sp = (SerialPort)sender;  
        string indata = sp.ReadExisting();  
        Console.WriteLine("Data Received:");  
        Console.Write(indata);  
    }  
    

    }

    0 comments No comments

  4. Castorix31 81,721 Reputation points
    2022-07-08T11:01:14.103+00:00

    .Net 6.0 evidently has removed such information.

    In .NET 6, add the NuGet Package : System.IO.Ports

    0 comments No comments

  5. Chetty 31 Reputation points
    2022-07-08T14:12:59.91+00:00

    I could find the following: System I.O, Compression & CompressionZip, System I.O. File system & File system primitives but no System I.O. Ports. I found this under the Tools /Nuget. Maybe I am not doing this properly.