locked
The handle is invalid

    Question

  • Anyone know what would cause this exception and what handle it is talking about.

    I am just calling the Socket BeginConnect method.  It doens't occur all the time it just appeared randomly.

     

    ipepServer = new IPEndPoint(server, port);

    ws_socket.BeginConnect(ipepServer,new AsyncCallback(IOComplete),State);

     

    System.ApplicationException: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
       at System.Threading.ThreadPool.BindIOCompletionCallbackNative(IntPtr fileHandle)
       at System.Threading.ThreadPool.BindHandle(SafeHandle osHandle)
       at System.Net.Sockets.Socket.BindToCompletionPort()
       at System.Net.Sockets.BaseOverlappedAsyncResult.SetUnmanagedStructures(Object objectsToPin)
       at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
       at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state)
    Thursday, November 29, 2007 2:33 PM

All replies

  • Solved.

    What was happending is that a COM object in the same process using window sockets would call close on the same handle more then once.

    So what was happending I assume is the COM object would use a handle, close it, dotnet would some how create a new connection and get the same handle value, then the COM object would call close on the old handle.


    Tuesday, January 29, 2008 4:25 PM