Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: An access violation occurs when IIS 6.0 recycles a worker process for an ASP file that calls a .NET managed component


View products that this article applies to.

Symptoms

Consider the following scenario. You have a Microsoft Active Server Pages (ASP) file that calls a method that is in a .NET managed component. A client Web browser requests the ASP file. In this scenario, when Microsoft Internet Information Services (IIS) 6.0 recycles the worker process, an access violation occurs. The following Warning event is logged in the System log:

Event Type: Warning
Event Source: W3SVC
Event Category: None
Event ID: 1009
Date: Date
Time: Time
User: N/A
Computer: ComputerName
Description: A process serving application pool 'ApplicationPoolName' terminated unexpectedly. The process id was 'ProcessID'. The process exit code was '0xc0000005'.

Additionally, the following Error event may be logged in the Application log:
Event Type: Error
Event Source: COM+
Event Category: Unknown
Event ID: 4786
Date: Date
Time: Time
User: N/A
Computer: ComputerName
Description: The system has called a custom component and that component has failed and generated an exception. This indicates a problem with the custom component. Notify the developer of this component that a failure has occurred and provide them with the information below.
Process Name: w3wp.exe
Exception: C0000005
Address: 0x79202781
Call Stack:
mscorwks!GetCompileInfo + 0x277d0
mscorwks!GetCompileInfo + 0x3151f
mscorwks!GetCompileInfo + 0x31550
mscorwks!GetCompileInfo + 0x314b5
mscorwks!GetCompileInfo + 0x317fc
mscorwks!GetCompileInfo + 0x30d02
mscorwks!GetCompileInfo + 0x31a52
mscorwks!GetCompileInfo + 0x31a2d
ole32!CoQueryAuthenticationServices + 0x1ae5
ole32!CoQueryAuthenticationServices + 0x22fa

↑ Back to the top


Cause

This problem occurs because the common language runtime (CLR) maintains a reference to the intrinsic object after the ASP module has unloaded. When IIS recycles the worker process, the CLR releases the reference to the intrinsic object that the ASP module deleted when it unloaded. This behavior causes an access violation.

This problem can occur if all the following conditions are true:
  • The .NET managed component is a Microsoft COM+ serviced component.
  • The .NET managed component sets the IISIntrinsics attribute to True.
  • The .NET managed component uses the ContextUtil class to access an IIS intrinsic object.
Additionally, this problem can occur if either of the following conditions is true:
  • The ASP code explicitly passes a reference to an IIS intrinsic object to a .NET managed component. The .NET managed component does not have to be a COM+ serviced component.
  • The ASP code implicitly passes a reference to an IIS intrinsic object to a .NET managed component. See the ASP code example in the "Workaround" section for an example of this scenario. The .NET managed component does not have to be a COM+ serviced component.

↑ Back to the top


Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this problem, use one of the following methods. Use the method that fits your situation the best.

Method 1: Convert method parameters to explicit data types in the ASP code

You can modify the ASP code to pass an explicit data type to a method that is in the .NET component. For example, consider the following ASP code example.
<%
   Dim obj
   Set obj = Server.CreateObject("<ProgID>")
   obj.<MethodName> Request.ServerVariables("<ServerVariable>")
   Response.Write("Call Completed!")
   Set obj = Nothing
%>
You can modify this ASP code example to use the CStr VBScript conversion function to explicitly pass a string data type to a .NET component method.
<%
   Dim obj
   Set obj = Server.CreateObject("<ProgID>")
   obj.<MethodName> CStr(Request.ServerVariables("<ServerVariable>"))
   Response.Write("Call Completed!")
   Set obj = Nothing
%>
For more information about the VBScript conversion functions, visit the following Microsoft Developer Network (MSDN) Web site:

Method 2: Call the Marshal.ReleaseComObject method in the .NET component

If the .NET component is a COM+ serviced component that uses the ContextUtil class to explicitly access IIS intrinsic objects, you can call the Marshal.ReleaseComObject method in the .NET component. This method explicitly releases the IIS intrinsic object. For more information about the Marshal.ReleaseComObject method, visit the following MSDN Web site:

↑ Back to the top


Status

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

↑ Back to the top


Keywords: KB918329, kbbug, kbtshoot, kbprb, kbasp

↑ Back to the top

Article Info
Article ID : 918329
Revision : 5
Created on : 12/3/2007
Published on : 12/3/2007
Exists online : False
Views : 433