the code:
static void Main(string[] args)
{
Console.WriteLine(\"Memory mapped file reader started\");
using (var file = MemoryMappedFile.OpenExistin
Hans' answer supercedes this one; I am leaving it for context and informational purposes only.
You need to close the port when you are done with it. The garbage collector is not collecting the first SerialPort object before you try to open another handle to it. Change this code:
SerialPort port = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
port.Open();
port.Write(reader.ReadElementContentAsString() + ",");
To:
using (SerialPort port = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One)))
{
port.Open();
port.Write(reader.ReadElementContentAsString() + ",");
}