I have a utility which connects to a device through a serial port. To test this application I'm writing a simulator for the device.
Both applications are intended to run on the same Windows 7 machine.
I'm writing the simulator in C#. I used com0com to create a pair of virtual ports (in this case - CNCA8 & CNCB8, since I already have several existing pairs).
I'm trying to open CNCB8 in the simulator (application is not running yet), and I get an exception:
An unhandled exception of type 'System.ArgumentException' occurred in System.dll
Additional information: The given port name does not start with COM/com or does not resolve to a valid serial port.
Sample code:
SerialPort port = new SerialPort("CNCB8", 9600, Parity.None, 8, StopBits.One);
port.Handshake = Handshake.None;
port.Open();
This question is not relevant since it's an unused virtual port (IsOpen returns false if that matters): C# SerialPort#Open() method throws ArgumentException because of port name?
EDIT: I also made sure that the port name appears in SerialPort.GetPortNames(), and it appears in WIndows' device manager under 'com0com serial port emulators'. I also tried using CNCA instead of B (with a few different existing virtual ports), tried to remove the 'HandShake' line and tried changing the baud rate to 115200, just in case (although ultimately I need 9600 there).