CannotUnloadAppDomainException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HKannen

    #1

    CannotUnloadAppDomainException

    Hello Everybody

    we are calling a Socket.SendTo( buffer, remote ) in a method in our Web
    Service.
    After doing this the Web Service won't stop any longer.

    We get an System.CannotUn loadAppDomainEx ception whenever we have called the
    method mentioned above.

    If we haven't called the method that opens a socket we can stop the
    WebService without any problems.

    See the code below and PLEASE help me :-)

    public static ArrayList PingHost( Int32 lWaitTime )
    {
    //Initilize a Socket of the Type ICMP
    socket = new Socket( AddressFamily.I nterNetwork,
    SocketType.Raw,
    ProtocolType.Ic mp );

    ......

    nBytes = socket.SendTo( sendbuf,
    PacketSize,
    SocketFlags.Non e,
    epServer );
    if( nBytes == SOCKET_ERROR )
    {
    throw new Exception("Sock et Error");
    }

    .......

    while( System.Environm ent.TickCount < dwStart+lWaitTi me )
    {
    if( socket.Poll( lWaitTime, SelectMode.Sele ctRead ) )
    {
    nBytes = socket.ReceiveF rom( ReceiveBuffer,
    lLength,

    SocketFlags.Non e,
    ref
    epServer );
    }
    }

    .........

    if( socket != null )
    {
    socket.Shutdown ( SocketShutdown. Both );
    socket.Close();
    socket = null;
    }
    return RetVal;
    }

Working...