I try to send custom objects (dataset/serializable object, etc...) to clients from the server
the communication works fine, and i receive data when i use short string but now, i have implemented server side to send custom objects and since this implementation, i cannot deserialize back in the clients...
what i discovered is when i use customs objects, i received twice call from the server, i'm not sure of it but it seems that the client do a "beginread" to quickly and the server has not enough time to send the object entirely so it sends data "chunked"?
can you help me?
here the Server code to send data to clients :
Dim dataExch As New DataExchange(Subscription, Data)
'serialize the dataExchange class in binary format
ms = ClsMisc.SerializeBinary(Of DataExchange)(dataExch)
If ms IsNot Nothing Then
'convert the memorystream to get a full string to be send in plain text
Data = System.Convert.ToBase64String(ms.ToArray)
If Me._subscriber.GetStream.CanWrite Then
Dim writer As New IO.StreamWriter(Me._subscriber.GetStream)
Client code :
Dim BytesRead As Int32
Dim strMessage As String
' Finish asynchronous read into readBuffer and return number of bytes read.
BytesRead = Me._client.GetStream.EndRead(ar)
Catch e As Exception
If BytesRead < 1 Then
' If no bytes were read server has close. Disable input window.
Dim ms As New MemoryStream
Dim b() As Byte = System.Convert.FromBase64String(strMessage)
ms.Read(b, 0, b.Length)
'HERE I CANNOT DESERIALIZE THE DATAEXCHANGE CLASS
Dim ds As DataExchange = ClsMisc.DeSerializeBinary(Of DataExchange)(ms)