I've created some code which runs a Socket asynchronously. This code has been fine until recently, where now, any time the client socket is either ungracefully exit, or if the connection attempt fails, the code fails with an unhandled AccessViolationException producing the following:
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="System"
StackTrace:
at System.Net.UnsafeNclNativeMethods.OSSOCK.WSAGetOverlappedResult(SafeCloseSocket socketHandle, IntPtr overlapped, UInt32& bytesTransferred, Boolean wait, IntPtr ignored)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
Now, I've seen this before on the forums dealing with Remoting and various other networking technologies. So I checked the event log looking for the culprit DLL,
and it seems to be failing in kaseyasp.dll.
I may not be able to remove this, I will double check with IT.
The question I have, is there a hotfix for this problem I don't know what has changed on the machine, as I may have gotten a push from IT for something relating to this.

AccessViolationException when issuing BeginConnect
Tryst
Cammyr
Microsoft released a hotfix for this, but you must call Microsoft to request it, so until Microsoft releases the hotfix in Windows Update there is no way to make a reliable sockets application in .NET 2.0.... unless nobody use antivirus :p
The KB article is here http://support.microsoft.com/default.aspx scid=kb;EN-US;923028
Alexander Petukhov
soanfu
The following is the call. If there is an available target for the connection, the connect call responds correctly. However, if there is no target, an unmanaged thread (not trappable) is throwing the exception, as the exception is thrown after this call executes. If a connection can be established, the exception occurs upon severing the connection.
Please note that this code worked until very recently. No code was changed from when it worked to when it did not.
Like I said, this mirrors a similar issue found with Remoting applications, and the issue appears to be in the LSP layer as DLLs implementing an LSP are typically the faulting modules.
protected override void Reconnect()
{
bool error = false; try{
base.Reconnect();InitializeSocket();
m_clientClosed =
false; this.State = PeerState.Opening;m_remoteEndPoint = ResolveRemoteEndpoint();
m_socket.BeginConnect(m_remoteHost, m_remotePort,
this.CompleteConnect, m_socket);}
catch (SocketException e){
this.SignalError(Resources.ConnectionError, e.ErrorCode.ToString(System.Globalization.CultureInfo.CurrentCulture) + " - " + e.Message);error =
true;}
catch (ObjectDisposedException){
true;}
catch (ArgumentException e){
this.SignalError(Resources.ConnectionError, e.Message);error =
true;}
catch (FormatException e){
this.SignalError(Resources.ConnectionError, e.Message);error =
true;}
finally{
if (error){
}
}
}
Docpro777
Sorry but you code doesnot explain the hole story. I was getting this error once due to Thread safety and collection and I got rid of it using Locking.
May be you can debug the code to see what part of it is raising exception.
Best regards,
Rizwan aka RizwanSharp
talha zia
Can you please post your code. So we can have a check what's going wrong, IS there any shared resource at server end which is getting grabled when a client is disconnected so you are getting this error.
So its better to post the code.
Best Regards,
Rizwan aka RizwanSharp