Microsoft KB Archive/918329

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

Article ID: 918329

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft COM+ 2.0 Standard Edition
 * Microsoft Active Server Pages 4.0
 * Microsoft Windows Server 2003 Service Pack 1
 * Microsoft Internet Information Services 6.0

-





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:

Time:

User: N/A

Computer:

Description: A process serving application pool ' ' terminated unexpectedly. The process id was ' '. 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:

Time:

User: N/A

Computer:

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



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 &quot;Workaround&quot; section for an example of this scenario. The .NET managed component does not have to be a COM+ serviced component.



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(&quot;&quot;) obj. Request.ServerVariables(&quot;&quot;) Response.Write(&quot;Call Completed!&quot;) 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(&quot;&quot;) obj. CStr(Request.ServerVariables(&quot;&quot;)) Response.Write(&quot;Call Completed!&quot;) Set obj = Nothing %> For more information about the VBScript conversion functions, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/51b7aeaf-e58d-4f7b-b992-ca6cfd0a3fe1.asp

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:

http://msdn2.microsoft.com/en-US/library/system.runtime.interopservices.marshal.releasecomobject.aspx



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbasp kbprb kbtshoot kbbug KB918329

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.