SerialPort USB - .Net 4.0 RRS feed

  • General discussion

  • For some time there were  problems with USB SerialPort adapters.  Probably the easiest way to see the difficulty was to pull the USB adapter while the port was in use.  What resulted seemed to depend on some set of factors that I never fully understood.  What I saw was my programs crash, or the SerailPort would not be usable until the PC was rebooted, or both, or etc...

    Recently I tested the .Net 4.0 SerialPort by pulling the adapter while the port was in use.  My program did not crash, and I was able to re-use the port without restarting my PC.  I am hoping that others that regularly use the SerialPort will post comments about their experience with .Net 4.0. 


    Subnet Calculator / Planner       Serial Port       Random
    Thursday, August 19, 2010 6:00 PM

All replies

  • Serialport unplug and plug

    I had seen that, and... 

    Subnet Calculator / Planner       Serial Port       Random
    Thursday, August 19, 2010 11:12 PM
  • I have not had the same issues with the SerialPort object in 4.0 that I'd had with earlier versions.  Have you tried my Enhanced SerialPort?  It includes a Watchdog, which will automatically reconnect a USB serial port if detached and subsequently reattached (with caveats), along with a PortDescriptions() method.  Enhanced SerialPort is a wrapper of the .NET 4 version.

    The result is a SerialPort object that now is equivalent to the DesktopSerialIO dll that I developed a number of years ago, which did not suffer from  the problems that the earlier .NET Framework versions had.


    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See
    Friday, August 20, 2010 4:31 PM
  • The SerialPort can now be disconnected and opened after reconnection without the problems detailed in the link in my previous post.  Run this code and disconnect the port.  Reconnect the port and press the button.

    Imports System.IO.Ports
    Public Class Form1
    Private Sub Form1_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load
    End Sub
    Delegate Sub AddText(ByVal Txt As String)
    Sub SerialPort1_DataReceived(ByVal sender As ObjectByVal e As SerialDataReceivedEventArgsHandles SerialPort1.DataReceived
    New AddText(AddressOf TextBox1.AppendText), SerialPort1.ReadLine() + Environment.NewLine)
    End Sub
    Private Sub ToolStripMenuItem1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles ToolStripMenuItem1.Click
    End Sub
    End Class

    Friday, August 20, 2010 6:07 PM
  • The SerialPort 4.0 port can  now be disconnected and reconnected, but It now has another problem.  If you start an app with the port connected and open and then disconnect the port, you get an error when you close the app.  This is new.  It doesn't happen with the SerialPort 2.0.

    If you have a workaround post here:

    Thursday, January 27, 2011 6:46 PM