Two programs can't have the serial port open at the same time. Attempting to open a serial port throws that exception under these circumstances:
Access is denied to the port.
-or-
The current process, or another process on the system, already has the specified COM port open either by a SerialPort instance or in unmanaged code.
Source. So you can't have the serial port open in your program, and also in test.exe
.