ASP components aren’t released by setting their references to Nothing

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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS