TlsSocket.EndSend() throws System.InvalidCastException

0 votes
asked Apr 9, 2018 by yuretz (180 points)

Hello,

I've run into the following issue: whenever I try to finalize an asynchronous send operation with TlsSocket.EndSend(), I get the following exception:


System.InvalidCastException: InvalidCastException
at Rebex.Net.TlsSocket.EndSend(IAsyncResult asyncResult)
at Infrastructure.Communication.SecureTcpClient.SendCallback(IAsyncResult result)
at tlqh.fehz(Object dqv)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()

The code that provokes it looks something like this:

// start asynchronous operation
socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, SendCallback, socket);

// ... some lines skipped
private void SendCallback(IAsyncResult result)
{
    TlsSocket socket = (TlsSocket) result.AsyncState;

    socket.EndSend(result);

    //... further processing 
}

I'm using the latest 2018 R1 version of the library under .NET Compact Framework 3.5 on Windows CE.

Could you please help me to solve this issue?
Thanks in advance.

1 Answer

0 votes
answered Apr 9, 2018 by Lukas Pokorny (100,250 points)
selected Apr 10, 2018 by yuretz
 
Best answer

Hello,

It seems that TlsSocket.EndSend throws InvalidCastException when an error occurred during the asynchronous operation. This is caused by a bug in EndSend's error handling. We will fix this quickly and send you a link to a hotfix. Thanks for bringing this issue to our attention!

commented Apr 10, 2018 by yuretz (180 points)
Sounds good, thank you!
commented Apr 10, 2018 by Lukas Pokorny (100,250 points)
I just sent a link to the hotfix to your e-mail address.
commented Apr 10, 2018 by yuretz (180 points)
Awesome, thanks a lot!
...