错误代码:
Server Error in '/' Application.
--------------------------------------------------------------------------------由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作。 219.142.78.189:25 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Sockets.SocketException: 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作。 219.142.78.189:25Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: 
[SocketException (0x2747): 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作。 219.142.78.189:25]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224[WebException: Unable to connect to the remote server]
   System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +5420699
   System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +202
   System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
   System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +332
   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +160
   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +159
   System.Net.Mail.SmtpClient.GetConnection() +35
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1213[SmtpException: Failure sending mail.]
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1531
   changketuan.WebForm6.Button1_Click(Object sender, EventArgs e) +301
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 ====================================
现象分析,以上是发电子邮件代码,在本机测试没问题。放到服务器就出现以上错误,重启服务器后又能正常,但过一段时间来测试后,又出现以上错误了。
求助解决方案。

解决方案 »

  1.   

    估计是资源没释放,查查SmtpConnection这类是否都是释放了
      

  2.   

    每次发送邮件完毕后记得Dispose或Clear相关对象即可!
      

  3.   

    我在服务器的进程里,把svchost.exe  句柄数为18360
    结束掉,就可以发电子邮件了。
    但具体的不知是什么原因造成的?
      

  4.   

    我的发电子邮件代码是怎么写的,如何增加“对象释放”、“资源释放”、“清空缓存”MailMessage mailMsg = new MailMessage();
                mailMsg.From = new MailAddress("[email protected]");
                mailMsg.To.Add("[email protected]");
                mailMsg.Subject = " 您的邮箱激活邮件";
                mailMsg.Body = "亲爱的会员您好";
                mailMsg.IsBodyHtml = false;
                mailMsg.Priority = MailPriority.High;            SmtpClient client = new System.Net.Mail.SmtpClient();
                client.Host = "smtp.sina.com";
                //client.Port = 587;
                //client.EnableSsl = true;
                client.Credentials = new System.Net.NetworkCredential("[email protected]", "1234");
                client.Send(mailMsg);
      

  5.   

    SmtpClient 类没有 Finalize 方法,因此应用程序必须调用 Dispose 来显式释放资源。 Dispose 方法在所有建立到 Host 属性中指定的 SMTP 服务器的连接中循环,并发送 QUIT 消息,其后平稳断开 TCP 连接。 Dispose 方法也释放由 Socket 使用的非托管资源,并根据需要释放托管资源。 
      

  6.   

    client没有Dispose属性或方法;
    不过mailMsg倒是有,mailMsg.Dispose;
    不知能不能解决我的问题