This seems to be a problem with reflection. Everything works fine up until reflection code is added.
Code:
Public Sub ConfigureClient(ByVal client As TcpClient, _
Code:
ByVal direction As ConversationDirection)
' Set it up...
_client = client
_direction = direction
' Update the window...
UpdateCaption()
' Get the stream...
_stream = _client.GetStream()
' Get the socket through reflection...
Dim propertyInfo As PropertyInfo = _
_client.GetType().GetProperty("Client", _
BindingFlags.Instance Or BindingFlags.NonPublic)
If Not propertyInfo Is Nothing Then
_socket = propertyInfo.GetValue(_client, Nothing)
Else
'This is the exception that is thrown ever since reflection was added
Throw New Exception("Couldnât retrieve Client property from TcpClient")
End If
' Spin up the threads...
_transmitThread = New Thread(AddressOf TransmitThreadEntryPoint)
_transmitThread.Start()
_receiveThread = New Thread(AddressOf ReceiveThreadEntryPoint)
_receiveThread.Start()
End Sub
----------------------------------------------------------------
'Program halts on this line...
Protected Sub ProcessConnection(ByVal client As TcpClient, _
ByVal direction As Conversation.ConversationDirection)
' Do you have to move to another thread?
If IsMainThread() = False Then
' Create and call...
Dim args(1) As Object
args(0) = client
args(1) = direction
Invoke(New ProcessConnectionDelegate(AddressOf ProcessConnection), _
args)
Return
End If
' Create the conversation window...
Dim conversation As New Conversation
conversation.Show()
conversation.ConfigureClient(client, direction)
End Sub
-----------------------------------------------------
Any ideas besides omitting the reflection and letting the program error on disposal?
Thanks