8
Answers

Serial Port problem

Ryan Alford

Ryan Alford

16y
15.8k
1
I am writing an application that listens to a serial port(COM1) for input from a barcode scanner.  The problem I am having is when I move between different forms.  In the form load event on each form, I set the port name:

serialPort.PortName = "COM1"

to the correct COM port.  Whenever I am ready to move to another form, I call:

serialPort.Close()
serialPort.Dispose()

However, when I open the next form, I get the "access denied" error when trying to open the port again.

I am using the SerialPort control on the form rather than programmatically creating a serialPort.
Answers (8)