PRB: Application.Lock and Application.UnLock Cause Server to Hang in IIS 5.0 (271787)
The information in this article applies to:
- Microsoft Internet Information Server 5.0
This article was previously published under Q271787 SYMPTOMS
When you modify Application variables from within a component that is called from an Active Server Pages (ASP) page, your server may stop responding (hang). The code in the component that causes the problem resembles the following:
Application.Lock
Application("myvar") = "hello world"
Application.UnLock
CAUSE
Code that is embedded in the Application.Lock and Application.UnLock methods provides protection in a multi-user environment. With the introduction of COM+, Internet Information Server (IIS) 5.0 takes advantage of the Thread-Neutral Apartment (NA) when accessing the Application object. As a result, when you explicitly call Application.Lock and Application.UnLock from within a component, under certain scenarios you might encounter a deadlock scenario that causes the server to stop responding. This problem is most commonly seen when ASP intrinsics are marshalled back and forth between the IIS server and the COM+ Application server. The following two scenarios may cause the server to hang:
- When you debug a Microsoft Visual Basic component from the Visual Basic Integrated Development Envrionment (IDE).
- When you call a component that is running as a Server application in COM+.
RESOLUTION
The Application.Lock and Application.UnLock methods are not needed to assign a single Application variable because the methods are called internally.
If you need to assign multiple Application variables within the same Application.Lock and Application.UnLock methods from your component, your component must run in the same process as the caller, or you must modify your logic to only include a single assignment. For example, the following code
Application.Lock
Application("myvar1") = "hello"
Application("myvar2") = "world"
Application.UnLock
could be modified to work around this issue as follows:
Dim array(1)
array(0) = "hello"
array(1) = "world"
Application("myvar") = array
NOTE: This is only one example. There are numerous ways that you can change your logic to work around this issue.
Modification Type: | Major | Last Reviewed: | 6/25/2004 |
---|
Keywords: | kbprb KB271787 |
---|
|