ASPCompiler Program IDs
ASP Compiler 1.1 documentation is under development. See also the examples.

Program IDs

Program ID is used by the Windows OS to recognize a COM class and create an instance of it. ASPC generates code for COM class intended for in-process usage. This means all the generated classes are placed in the resulting DLL. Every ASP page or other kind of VBScript file becomes a COM class in this DLL. Thus one DLL may contain several classes and they all are recognized from each other by their program IDs.

ASPC generates loader files (ASP or plain VBScript) intended to create an object of the appropriate class (corresponding to the original page or script) and execute it. It will he helpful to take a look at the code in these files and see what they are really doing. Here is a sample one:

Dim proc
Set proc = Server.CreateObject("ASPCPrjX.cls0page_asp")
Set proc.Application = Application
Set proc.Request = Request
Set proc.Response = Response
Set proc.Server = Server
Set proc.Session = Session

As you can see there is nothing mystic here. Your page is in the COM class and it is created by using the CreateObject function and then its properties are set.

CreateObject uses the class program ID and it requests an instance of your class from the system passing this ID to it. Then the system loads the DLL containing the class,  creates an instance of it and returns a reference to the newly created object to the caller. The system looks in the registry for the program ID and learns which is the corresponding DLL from the values found for it. Thus all the objects creatable using the CreateObject function (or equivalent routine in other languages) are registered in the system registry.

ASPC generates the program IDs as follows:

They consist of two parts:


ProjectName is exactly the project name you entered in the project settings.

ClassName is generated automatically. ASPC generates unique names for every page/script in the project by combining a clsX prefix and the file name ("." is replaced with "_"). X is a number unique for every page - usually its ordinal number in the project. The VBScript classes defined by the developer are not registered in the registry and thus are not creatable by default.

As you can see the project name is very important because if two projects share the same name then there is a considerable chance that you will have different classes with the same program IDs and registration of one of the DLLs will remove registration of some classes from the other DLL.

This may cause very unpleasant situations such as corrupting one application by compiling another. To prevent such problems you should pay special attention to the project names and the ClassName directive if you want to control the class naming process yourself.

As a general recommendation we recommend to use different project names for every project and also use the ClassName directive in every case in which the application development will continue in the future. This will ensure that the names for the generated classes are under your control and any change in the project definition (file order, set of the files) will not change their program IDs. Also this will allow you to not change the loader files from earlier compilations and if the DLLs are used on many machines you will need to update only them with the newer versions.

If you are using the Public or Creatable directives this will cause the affected VBScript classes to be registered in the registry as like the COM classes generated from your pages. In such cases you can think for the above recommendation as for an requirement, because any future change in your projects may cause program IDs to change and thus make your classes inaccessible.

How to plan the project names?

With ASPC ASP and VBScript developers have an opportunity to convert some of their pages/scripts to COM Dlls intended for wide usage in another applications and not just in place of the original scripts/pages. If this is your case you should be twice more careful with the program IDs and be aware that your components will be registered on systems which are not under your control and your program IDs must not cause collisions with the program IDs of the other components on these systems.

You can base the project name on a combination of your company name and project purpose. Unfortunately VB has a limitation for the program ID length thus we recommend to fit your project name in about 20 characters in order to avoid compilation errors in VB.

Although class names may look not so important in this case you should keep in mind that you may continue to supply components for your customers in future and take care to choose meaningful names for them. This will help you to troubleshoot the customers and replace the classes with newer versions.

All the problems discussed on this page are a result of the fact that an ASP page (for example) is used for applied purposes which depend on the application. Pages are often copied and modified to match similar needs in another site. But using ASPC your pages become something a bit more closer to the system programming - components which in theory can be used in many applications without change. Thus the VBScript programmers without experience in development of retail software will meet problems not typical for their former programming style. We hope this chapter explains the most important things and helps them to avoid mistakes caused by wrong selection of program IDs and respectively the ASPC project name and ClassName directive. Your suggestions will be very useful for the future improvement of this documentation. Copyright 2001-2006 newObjects [ ]