Connection error

Oct 17, 2011 at 6:15 PM

I'm trying to use COM interop objects to read a GPS from my Silverlight OOB application.  When I attempt to open the port for reading I get the following error:

"The I/O operation has been aborted because of either a thread exit or an application request"

Here is the code I'm using:

 Dim pr As New System.IO.Ports.SerialPort(cboPorts.SelectedValue.ToString, 4800, IO.Ports.Parity.None)
            pr.Open() 
            Dim Incoming As String = pr.ReadExisting

Oct 19, 2011 at 12:09 AM

Hi abowne.

I have never heard about that error and it is definitively not created by Silverlight Interopcom. As far as my researches went, it could be something with USB (do you have USB-serial-connection?) or chipset-drivers.

The only thing I can tell you so far is, that it is not one of my error messages and that I have never come across it.

I will investigate further and would be glad, if you posted the solution, if you should find it.

 

Regards,

Paul

Oct 19, 2011 at 2:56 PM

Paul,

Yes, my GPS device is connected via USB thru a virtual COM port.  I imagine this must be the issue.  Can you think of a workaround?

 

-Andrew

Oct 20, 2011 at 12:01 PM
Edited Oct 20, 2011 at 12:06 PM

Maybe you should start trying to get a signal from your GPS to a 'normal' application, like e.g. Putty. If this does not work either I would suggest reinstalling the drivers.
If it works flawlessy with the software you chose to test, I have no idea for now. But I think, it actually is a USB-serial-problem.

Maybe you should check this thread:

http://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_install/usb-driver-installation-issue-the-io-operation-has/c49aced6-71b3-475b-8e53-1d5fddf1fc06

Regards,
Paul

Oct 20, 2011 at 8:32 PM

I used Putty as well as ArcMap (GIS Application) and both were able to read the incoming GPS data.

-Andrew

Oct 21, 2011 at 1:24 PM

Alright,

have you used the source or the binaries? If you used the source-code you should be able to track the souce of the exception (as long as it occurs in the SLSerialPort.dll). If the exception is thrown in the COM-object you would need to create another project wich uses the dll directly (not via COM interop) for debugging. Have you tried simplifying your code to avoid dead-locks?

Maybe I can have a look at your code to see what's going on? Eventually I could reproduce the error that occurs to you and find a solution.

Regards,

Paul

Oct 21, 2011 at 2:53 PM

Paul,

The plot thickens:  I am no longer getting the error that I was experiencing before.  Now, when I do actually make a connection, my application crashes with no error.

I am using the binaries.

My code is very basic.  I will attach it below.  Basically I have a combobox populated with the port numbers and a "Connect" button.  when the port opens I subscribed to the DataReceived Event Handler to pass the incoming data to a textblock.

When I click "Connect" I can step through the code, open the port, etc.  However the event handler is never fired.  When I get to the end of the button_click event, the application crashes with no error.  

Here's my code:

 Private Sub BtnConnect_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles BtnConnect.Click
        Try
            Dim pr As System.IO.Ports.SerialPort = New System.IO.Ports.SerialPort(cboPorts.SelectedValue.ToString, 4800, IO.Ports.Parity.None)
            If Not pr.IsOpen Then
                pr.Open()
                AddHandler pr.DataReceived, AddressOf GPSIncoming
            End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
    Private Sub GPSIncoming(ByVal sender As Object, ByVal e As IO.Ports.SerialDataReceivedEventArgs)
        Try
            Dim sp As System.IO.Ports.SerialPort = CType(sender, IO.Ports.SerialPort)
            Dim indata As String = sp.ReadExisting()
            Me.txtIncoming.Text = indata.ToString
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
    Private Sub cboPorts_DropDownOpened(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboPorts.DropDownOpened
        Dim prt As New System.IO.Ports.SerialPort
        Dim availprt As String() = prt.GetPortNames
        For Each port As String In availprt
            Me.cboPorts.Items.Add(port)
        Next
    End Sub

Thanks again for giving me a hand with this Paul.  Much appreciated.

-Andrew

Oct 23, 2011 at 10:31 PM

Hi Andrew,

sorry for the delayed answer. I searched the web a bit more regarding this issue. Maybe the error is in the COM-interop. But at the moment, I have little time to dive deep into the code.

I hope that I will find time to take a swift look on the code tomorrow – but I can not promise it.

About the crashes: have you unlocked the installer, sometimes this is needed. Once, I ran into crashes on a machine where I downloaded the files from codeplex and did not unlock them.

Sorry, I could not be of more help until now.

Regards,

Paul

Oct 24, 2011 at 8:09 PM

Paul,

I've doublechecked and the files are unlocked.  When I spin up the sample/demo on codeplex and click "connect" I get "Microsoft Silverlight Out-of-Browser Launcher has stopped working".  Close/Debug..

I also uninstalled the .dll's from the installer and installed the assemblies from the .reg file.

 

-Andrew

Oct 24, 2011 at 11:16 PM

Hi Andrew,

I can't find the clue. The net is full of the error-message in relation with threads. But I did not implement parts of the lib threaded. So it has to be the underlying SerialPort-Implementation or your app, that throws the exception.

I would ask you to use the sources and debug them with your code - of course you can only debug SLSerialPort.dll, not the other one, but this may help to narrow down the source of the error. As I don't have a machine/installation that produces this error alas, I have to base my assumption on your experience of the lib.

But I hope we get a grip on this.

Regards,

Paul