Posts

Showing posts with the label serial-port

Serial Port Unauthorized Exception

Serial Port Unauthorized Exception I am trying to access RFID Reader through Arduino application which gives me the right output on control monitor. But when I tried to access it through visual studio C#, it works only once and then gives me access is denied! And also stopped working on Arduino IDE. //Function to initialize serial port SerialPort RFIDPort public SerialPort initializeRFIDPort() { try { RFIDPort = new SerialPort("COM4",9600,Parity.None,8, StopBits.One); if (RFIDPort.IsOpen) RFIDPort.Close(); if(!RFIDPort.IsOpen) RFIDPort.Open(); } catch (UnauthorizedAccessException ex) {MessageBox.Show( ex.Message); } catch (Exception) { RFIDPort = null; } return RFIDPort; } I put the function here: public products() { InitializeComponent(); initializeRFIDPort(); } There is two scan button the first one for scanning and then add data to the database and the second button is to sc...