I use System.IO.Ports.SerialPort
to manage RS232 communication without any problem. However, more and more devices propose RS232 communication throw an USB connector which imply an emulated serial port on the PC.
My concern is when the device is turned off, the serial port is no longer available on the PC, and when I use the Close()
function to release the communication, I get an exception that I'm not able to catch by any try...catch
, and so the full application close (no just in time recover).
Checking step by step what happen it seems the serial port resource is disposed when I try to close it and that causes the failure.
Is there a way to know if the port is still available or catch the exception ?
I've also tried to list again available ports with System.IO.Ports.SerialPort.GetPortNames()
just before calling the Close()
function, but the port is still listed.
Thanks