Unhandled exception when disconnecting hub with serial converter
I have a setup with a USB hub, to which multiple serial devices are attached. I listed them below. I usually have 3 instances open, which I marked with an arrow.
COM3 ---- ---- Standard Serial over Bluetooth link (COM3) [SPPS De]
COM4 ---- ---- Standard Serial over Bluetooth link (COM4) [Bluetooth Peripheral Device]
COM6 1366 0105 USB Serial Device (COM6) [CDC] <--
COM11 1366 0105 USB Serial Device (COM11) [CDC] <--
COM24 0403 6011 USB Serial Port (COM24)
COM25 0403 6011 USB Serial Port (COM25)
COM26 0403 6011 USB Serial Port (COM26) <--
COM27 0403 6011 USB Serial Port (COM27)
The last four COM ports all belong to the same FTDI4232 Mini Module.
Whenever I reconnect any of the separate devices, recovery is all fine. However, when I disconnect the complete USB hub (causing the removal of all of above COM ports, except the Bluetooth ones), the SimplySerial instance using COM26 throws this exception:
Unhandled Exception: System.Management.ManagementException: Not found
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObject.InvokeMethod(String methodName, ManagementBaseObject inParameters, InvokeMethodOptions options)
at System.Management.ManagementObject.InvokeMethod(String methodName, Object[] args)
at SimplySerial.ComPortManager.GetPorts()
at SimplySerial.SimplySerial.Main(String[] args)
[process exited with code 3762504530 (0xe0434352)]
When I restart the instance it is fine again.
SimplySerial version 0.9.0
Installation Type : System
Installation Path : C:\Program Files (x86)\SimplySerial
Board Data File : 2025-03-04T20-57-17.992214
When detecting disconnected, SimplySerial should then only poll the COM port after verifying that it exists first. There could even be and option to set the detection interval when disconnected. I have about 3 out of 10 times getting an unhandled fault when disconnecting EPS32 modules as well. I often turn off a module for a quick change and then back on.