0

I'm using serial communication over USB and on start of the application, device is already connected and thing works fine. When I disconnect the device (Symulation an error) the application doesnt break,and if I try to reopen serialport from application it has no effect. Later , debugger says that disposal happend. I want to know, how to restore connection dynamically when device reconnects again. It all loops in timer

protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose(); ===> Exception is pointing at this
            }
            base.Dispose(disposing);
        }
user1480742
  • 145
  • 12
  • Without an [mcve] we can only guess – rene Sep 29 '15 at 20:50
  • "Later debugger says that disposal happened", does that mean you get an `ObjectDisposedException` somewhere? This is non-trivial, you may need to use management objects to notice the unplugging of a USB device and monitor for when the USB device is plugged back in. – Ron Beyer Sep 29 '15 at 20:52
  • I get a System.IOException was unhandled by user code => the device is not connected – user1480742 Sep 29 '15 at 20:55
  • You need to show us the code that is throwing the exception. – Ron Beyer Sep 29 '15 at 20:56
  • I would, if the code breaks and I get the line thats causes it. But applications doesnt break, I only get this in my Form1.Designer.cs while using the app => look at the edit...and this isnt something I wrote – user1480742 Sep 29 '15 at 20:59

0 Answers0