Unable to properly use VS Serial Monitor but Arduino IDE works

Simply put serial communication is usually communication between two devices, say device A and Device B.

Device A and B use a com port of some kind to communicate, as in your case it is com 3, usually A and B are the only devices allowed to use this com port.

Lets say device A is the arduino and device B is the PC, the sketch of the arduino has access to com 3 and so does the PC.

There is another rule we must be aware of and that is the PC is only allowed to use one application or program to access com 3 at a time. This means we can use a Visual Studio app or we can use the arduino IDE Serial Monitor app, we can NOT use both at the same time.

The solution is to build a serial monitor into your VS application. The following code is the beginning of a C# program as a simple monitor and test utility for serial comms.

Serial lines communicate using byte values, a byte can be a value from 0 to 255. When displaying text chars or strings the byte value will be in the range 32 to 127.The fact a serial byte can be a character or a numeric value is something both ends of the communication line need to be aware of. This makes more sense when you can actually see the results displayed from your serial transmissions. In this particular app Robin2 has an arduino program that echoes back the character you send, so we have a routine in VS that is purposely written to send and display a character

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using System.Collections;


namespace WindowsFormsApplication7
{
    public partial class Form1 : Form
    {

        SerialPort port = new SerialPort();
        public delegate void myDelegate(byte sData);

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            port.PortName = "COM3";
            port.Open();
            port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
            port.ReadExisting();
        }



        private void stringDebug(byte sData)
        {

            string s = Convert.ToString((char)sData);
            richTextBox1.AppendText(s);

        }


        private void port_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)

        {
            byte myData;
            port.ReadTimeout = 20;
            while (port.BytesToRead > 0)
            {
                try
                {
                    myData = System.Convert.ToByte(port.ReadByte());
                    this.BeginInvoke((new myDelegate(stringDebug)), myData);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            port.Write("A");
        }
    }
}

The routine displaying the character is the "stringDebug" delegate, modifying this routine allows us interpret the byte values in several different ways.

If you have any questions or would like to expand the sample serial monitor

I forgot to mention that the C# app has only two controls.....a richTextbox and a Button