The most common source of such errors is that the port is already open by some other application, or often with the help of a previous (completed, but forgotten to destroy) instance of your code.
To test this hypothesis, the easiest way is to run another program that opens the same port (for example, Hyperterminal) when you receive an error. If this fails, try to find who is holding the port.
In addition, Portmon is a useful tool for debugging similar serial port issues.
source share