This is my first SO question so please correct me where I am not supplying enough or correct information.
I'm interfacing two RFID tag readers via RS232 ports on a FTDI serial to USB hub to my program. The program runs perfectly outside VS2010, but I cannot debug the code. The program starts fine during debugging, but as soon as I bring a tag within reading proximity I get an error. This only happens during debugging.
The error:
Error Opening Serial Port COM9
System.UnauthorizedAccessException: Access to the port 'COM9' is denied.
at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
at System.IO.Ports.SerialPort.Open()
at Tag_Reader.COMs.openPort(String sPortName) in C:\XXX\Tag_Reader\COMs.cs:line 36
COMs.cs:line 36:
_port.PortName = sPortName;
_port.BaudRate = 9600;
_port.DataBits = 8;
_port.Parity = Parity.None;
_port.StopBits = StopBits.One;
_port.ReadTimeout = 500;
_port.WriteTimeout = 500;
_port.Open();
I would appreciate any help! As mentioned above the programs runs without a glitch if I run the .exe outside VS.
EDIT: This error only occurs during debug and only when there is data being streamed from the tag reader (when a tag is brought within the reader's reading proximity). This indicates that the port setup is correct.