|
|
|
If you instantiate an ActiveX component from an ASP script under IIS 4 and previous versions, using the Server.CreateObject command, you might believe that the object is deallocated as soon as you set its reference to Nothing - this is how all COM components work, right?
The problem with ASP components is that IIS keeps a private reference to the objects you instantiate from ASP scripts, and this reference is set to Nothing only after the entire ASP script has completed its execution. This extra reference is necessary to invoke the OnEndPage method when the ASP script has completed its execution.
In most cases this detail doesn't cause any problem, but sometimes it can be the source of very subtle bugs. For example, if your component contains some code in the Class_Terminate event, this code will be executed at the wrong moment. For example, if the code read a Session or Application variable, it can retrreive the wrong values. Worse, if the code sends HTML output through the Response ASP object, it won't work at all, because when the Class_Terminate event fires, the page has already been sent to the client browser.
Note that IIS5 deals with COM components in a smarter way: if the component doesn't expose an OnEndPage, when the ASP script sets the last reference to it is to Nothing the object is immediately destroyed. |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|