PRB: ??? System.InvalidOperationException ??? ??????? HttpWebRequest ??????? ???????? HttpWebResponse ?? ??????? ?? ???? ???? ???????

?????? ????????? ?????? ?????????
???? ???????: 815637 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

???????

??? ??????? System.Net.HttpWebRequest ????? System.Net.HttpWebResponse ?? ????? ?????? ???? ?????? ????? ?? ????? ????? ????? ???????:
System.InvalidOperationException: ??? ?? ??? ?????? ????? ??? ????? ?? ???? ThreadPool ?????? ???????

?????

System.Net.HttpWebRequest ? System.Net.HttpWebResponse ???? ?????? ??? ????? ??????? ???????? ??? ?????????. ??? ????? ??? ??? ?????? ? ?????? ASP.NET ???? ????? ???? ?? ???? ThreadPool. ????? ?? ??? ASP.NET ??? ???? ????? ??? System.Net.HttpWebRequest ?????? ????? ????? ????? ?? ??? ????? ?? ????? ????????.

???? ??????

??????? ?????? ??? ??? ??????? ?????? ???? ????? ???????:
  • ??????? ???? ???? ?????? ?? ????????? ???????? ???? ????????? ?????? ???? ?????.
  • ????? ???? ????? ???????? ???????? ????????? ????.
  • ?? ???? ??????? ASP.NET ?? ????? ??????? ???????? ?? Microsoft "??? 5.0 ?? ???? ????? ????? ??? ???? ???? ??????? ?? Machine.config ?????. ?????? ????? ???? ??????? ???????:
    1. ??? ????? Machine.config ?? ?????? \CONFIG Version \Microsoft.NET\Framework\ %Systemroot%.
    2. ?? ?????? <processmodel>????? Machine.config ?????? ??????maxWorkerThreads ????? maxIoThreads ??? ???? ??? ?? ?????? ??????? ?????? ?? CPU. ??? ???? ??????? ??? ???? ??? ?????? 25 ??? ???? ???? ??????? ? ?????? ASP.NET ????? ??? ??????? (API) ?????? ????? ?????? ?? ????? ??? 25. ??? ???? ??????? ????? ??? ????? ???? ??? 50.

      ?????? ?????? ??????? CPU ????? ???? ?????? ????? ?????? ??? ??????.
    3. ??? ????????? ??? ????? Machine.config.

?????

????? ??? ?????? ??? ???????.

??????? ????

  1. ????? ?? Microsoft Visual Studio .NET.
  2. ?? ??????? ???? ??? ??? ???? ?? ???? ??? ???????.
  3. ???? ??? ?????? Visual Basic ?? Visual C# ???????? ??? ????? Project ?? ???? ??? ????? ???? ?????? ??? ?????.
  4. ??????? ????? ?? ???? ????????? ???????? Class1 ???????? ???????? ???????? ???????? ??? ??? ???????:

    ??? Visual C# ?? .NET
    using System;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Threading;
    using System.Net.Sockets;
    
    namespace threadTest
    {
      
    	class Class1
    	{
    		 public static void Main()
    		{			
    		// Set number of threads to be created for testing.
    			int testThreads = 55;
    			for(int i=0;i<testThreads;i++)
    			{
    				ThreadPool.QueueUserWorkItem(new WaitCallback(PoolFunc));
    			}
    			Console.ReadLine();
    		}
    
    		static void PoolFunc(object state)
    		{
    			int workerThreads,completionPortThreads;
    			ThreadPool.GetAvailableThreads(out workerThreads,
    				out completionPortThreads);
    			Console.WriteLine("WorkerThreads: {0}, CompletionPortThreads: {1}", 
    			workerThreads, completionPortThreads);
    			Thread.Sleep(10000);
    			
    			string url ="http://www.msn.com";         
    			
    			HttpWebRequest myHttpWebRequest ; 
    			HttpWebResponse myHttpWebResponse=null ;        
    			// Creates an HttpWebRequest for the specified URL.    
    			myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); 
    			// Sends the HttpWebRequest, and waits for a response.
    			myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();            
    			myHttpWebResponse.Close();
    		}
    	}
    }
    
    Visual Basic .NET ???
    Imports System.IO
    Imports System.Net
    Imports System.Text
    Imports System.Threading
    Imports System.Net.Sockets
    
    Module Module1
    
       Sub Main()
          'Set number of threads to be created for testing.
          Dim testThreads As Integer = 55
          Dim i As Integer
    
          For i = 0 To testThreads
             ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf PoolFunc))
          Next
          Console.ReadLine()
    
       End Sub
       Public Sub PoolFunc(ByVal state As Object)
    
          Dim workerThreads, completionPortThreads As Integer
    
          ThreadPool.GetAvailableThreads(workerThreads, completionPortThreads)
    
          Console.WriteLine("WorkerThreads: {0}, CompletionPortThreads: {1}", workerThreads, completionPortThreads)
          Thread.Sleep(10000)
          Dim url As String = "http://www.msn.com"
          Dim myHttpWebRequest As HttpWebRequest
          Dim myHttpWebResponse As HttpWebResponse = Nothing
          ' Creates an HttpWebRequest for the specified URL. 
          myHttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
          'Sends the HttpWebRequest, and waits for a response.
          myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
          myHttpWebResponse.Close()
       End Sub
    End Module
  5. ?? ??????? ????? ? ???? ??? "????" ?????? ???????. ??? ?? ??? WorkerThreads ???????? ??? 0 ? ????? ????? ????? ??????? ?? ??? "?????? ?????".

?????

????? ?? ?????????? ?? ?????? ????? Microsoft ??????? ??? ?????:
????? ???? ???? ??????? ?? .NET Framework
http://msdn2.microsoft.com/en-us/library/ms973903.aspx

<processmodel>??????
http://msdn2.microsoft.com/en-us/library/7w2sway1(vs.71).aspx

???????

???? ???????: 815637 - ????? ??? ??????: 27/???? ??????/1435 - ??????: 1.4
????? ???
  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1
????? ??????: 
kbnosurvey kbarchive kbmt kbnamespace kbweb kbxml kbwnet kberrmsg kbconfig kbdev kbthread kbprb KB815637 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????815637

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com