.net - SerialPort visible in device manager but SerialPort.Open() reports that it cannot be found -


i have .net application listens on com port. other side of connection udoo board running lubuntu.

after udoo board rebooted, com port temporarily goes missing , re-appears on device manager. however, when call "open" function of serialport object, exception says "the port com4 not exist". full exception stack trace follows.

 @ system.io.ports.internalresources.winioerror(int32 errorcode, string str)    @ 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)    @ system.io.ports.serialport.open() 

even when exception thrown, device manager shows same com port visible in following screenshot.

enter image description here

and yes did refresh device list. unplugging , plugging cable computer solves problem but, isn't elegant.

are there thoughts on how work around problem ?

try disable serial port , reenable. check whether problem hardware. can check inserting usb device in serial port. if works proper. use debugger check code.


Comments