An ASP.NET application may experience delays if a request times out when the application invokes in-process COM+ components (917069)



The information in this article applies to:

  • Microsoft COM+ 1.5
  • Microsoft ASP.NET (included with the .NET Framework) 1.0
  • Microsoft ASP.NET (included with the .NET Framework 1.1)
  • Microsoft ASP.NET 2.0

SYMPTOMS

Consider the following scenario. A Microsoft ASP.NET application invokes in-process Microsoft COM+ components. The request times out at the precise moment as certain operations occur in a COM+ component. In this scenario, the COM+ runtime may report a fault to the Windows Error Reporting subsystem. Then, Windows Error Reporting may take actions that can cause additional delays in the application and compound the underlying problem.

CAUSE

This problem occurs when the time-out threshold for an ASP.NET request is exceeded. The ASP.NET runtime stops the request by throwing a ThreadAbortException exception for the thread that processes the request. If the ASP.NET request invokes an in-process COM+ component, and if any one of the IObjectControl methods of the component are running at the time of the ThreadAbortException exception, the COM+ runtime will catch the exception and report the fault to Windows Error Reporting. Then, Windows Error Reporting may create event log entries and communicate with error reporting servers. When this behavior occurs, the thread that runs the ASP.NET request will block, and the response is delayed. Windows Error Reporting may also create a dump file of the process. When this behavior occurs, the process is frozen, and all responses are delayed. Processes that host in-process (Library) COM+ applications are not terminated when these faults occur. Additionally, the cycle may repeat during subsequent time-outs and cause additional delays.

Note The sample in the "More Information" section uses a Microsoft .NET Framework ServicedComponent class. However, the same problem can occur if the application uses unmanaged COM+ components.

RESOLUTION

To resolve this problem, avoid the ASP.NET time-out. If the ASP.NET requests are not expected to exceed the time-out threshold, investigate and resolve the source of the underlying delays. The following methods can be effective tools to discover the source of the underlying delay:
  • Analyze dump files of the process that were taken when you experience the underlying delay.
  • Run the application under a profiler utility.
  • Use logging throughout the application.
In some scenarios, the requests should be expected to take longer than the default ASP.NET request time-out. In these scenarios, you should change the time-out value to a more appropriate value. To do this, use one of the following methods:
  • Use the executionTimeout setting.
  • Use the Server.ScriptTimeout property.

WORKAROUND

To work around this problem, you can change the COM+ application from an in-process (library) application to an out-of-process (server) application. In a server application, the COM+ components run in a separate process from the ASP.NET requests. Therefore, the COM+ runtime does not detect a ThreadAbortException exception, and the exception is not reported to the Windows Error Reporting subsystem.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Steps to reproduce the problem

  1. Follow the steps in Microsoft Knowledge Base article 306296 to create a simple ServicedComponent class and then install the class into COM+. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

    306296 How to create a serviced .NET component in Visual C# .NET

  2. Add the following code example to the ServicedComponent class.
    protected override void Activate()
    {
    	// Sleep for 100 seconds.
    	// (The default ASP.NET time-out is 90 seconds.)
    	System.Threading.Thread.Sleep(1000*100);
    }
    
  3. Create a Web application in Microsoft Visual C#. To do this, follow these steps:
    1. Start Microsoft Visual Studio .NET.
    2. On the File menu, point to New, and then click Project.
    3. In the New Project dialog box, click Visual C# Projects under Project Types, and then click ASP.NET Web Application under Templates.
    4. In the Location box, type http://localhost/TestWeb1.
    5. Click OK to create the project. WebForm1.aspx is added to your project.
  4. In Solution Explorer, right-click TestWeb1, and then click Add Reference.
  5. In the Add Reference dialog box, click Browse.
  6. In the Select Component dialog box, select the DLL that contains the ServicedComponent-derived class that you generated in step 1.
  7. In Solution Explorer, right-click WebForm1.aspx, and then click View Code.
  8. Add the following code example to the Page_Load event procedure.
    // Create an instance of the ServicedComponent-derived class.
    // Note: Change the namespace and the class name as appropriate.
    MyNamespace.MyServicedComponent sc = new MyNamespace.MyServicedComponent();
    
    // Call any method on this object to cause the Activate method to occur.
    sc.DoTrans();
    
  9. Use a stress test utility to test the http://localhost/TestWeb1/WebForm1.aspx page. For example, follow the steps that are listed in the following Microsoft Knowledge Base article:

    815161 How to measure ASP.NET responsiveness with the Web Application Stress Tool


Modification Type:MinorLast Reviewed:10/10/2006
Keywords:kbtshoot kbBug kbprb KB917069 kbAudDeveloper kbAudITPRO