SerialPort Open() throwing an Exception "Access to the port 'COM1' is denied"!!!

  • Thread starter Thread starter Soni.PJ
  • Start date Start date
S

Soni.PJ

Guest

While sending a command thr' SerialPort COM1, my API Open() is throwing an Exception!

try
{
serialPort = new SerialPort("COM1", 115200, Parity.None, 8, StopBits.One);
serialPort.ReadTimeout = 5000;







if(!serialPort.IsOpen)
serialPort.Open();




}


Even though 'IsOpen' property is 'false' confirming that port is NOT open, when I execute Next line: 'serialPort.Open()' it throws Exception as:



}



Even though 'IsOpen' property is 'false' confirming that port is NOT open, when I execute Next line: 'serialPort.Open()' it throws Exception as:





Even though 'IsOpen' property is 'false' confirming that port is NOT open, when I execute Next line: 'serialPort.Open()' it throws Exception as:


------------------
System.UnauthorizedAccessException was caught
Message="Access to the port 'COM1' is denied."
Source="System"
StackTrace:
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 CAN2bCommunication.ClassCAN2b..ctor() in D:\PROJECT WORK\EOLT1_To Mathias\CAN2bCommunication\ClassCAN2b.cs:line 89
InnerException:
------------------


<IMPORTANT> I have only once device connected to the port COM1, which responds with 'Hyperterm'.
Howeever, when I try to get the response, 'frequently' it throws Exception.

#1, I made sure that HyperTerm was disconnected
#2, Device was ON


Continue reading...
 
Back
Top