NickPyner:
tuxduino:
Nick, the OP has a problem with a C# program running on the PC, which gets data from Arduino. There's nothing a sketch can do here...OK. I said
this might be all you need
which still applies. And, in this case, the solution actually is in how the Arduino exports the data.
The OP error is this (please reread the first post):
"An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll Additional information: The port is closed."
This happens when the C# program tries to open COM4. At that point, how the data coming from Arduino is formatted is irrelevant.