A type library is a file that contains information about objects and types supported by a COM component. It is very common for a COM component to describe any constants that it supports in a type library. If your Web application relies on COM objects that have declared data types in type libraries, you can declare the type libraries in Global.asa. Doing so makes it possible to refer to the constants declared in the type libraries from any script within the application boundary.
For more information about using constants in ASP, see Using Variables and Constants.
The server can return one of the following error messages.
Invalid type library specification. The METADATA tag contains an invalid type library specification.
Type library not found. The METADATA tag contains a type library specification that does not match any registry entry.
Type library cannot be loaded. ASP cannot load the type library specified in the METADATA tag.
Type library cannot be wrapped. ASP cannot create a Type Library Wrapper object from the type libraries specified in the METADATA tag.
It is recommended that METADATA tags appear near the top of the Global.asa file. However, these tags can appear anywhere inside of the Global.asa file, including both inside and outside the SCRIPT tags.
You can avoid ambiguous references to constants by adding the type library name as a prefix for the constant. For example, ADODB.adErrItemNotFound would be less ambiguous than adErrItemNotFound.
If you use Microsoft ® Visual InterDev ® to create your Global.asa file, the METADATA tags includes the optional STARTSPAN and ENDSPAN keywords. These keywords are ignored by IIS.
If you do not specify a locale identifier for the type library, the default locale identifier for the system is used. If the system locale identifier cannot be used, and you have not specified a locale identifier, the locale identifier for the Type Library is set to 0.
MyComponent in the following example was developed using Microsoft Visual Basic ® Scripting Editing (VBScript), version 5.0. MyComponent defines the constant MyError with the following statement.
Public Const MyError = "You are not using MyComponent correctly."
The type library is contained in Mycomponent.lib, which is installed in the C:\MyComponent folder.
The following METADATA tag is included in the Global.asa file for the MyApp application:
<!--METADATA TYPE="TypeLib" FILE=" MyComponent.tlb" -->
Any .asp file in the MyApp application can now include the following script:
<% Dim MyVar Set MyVar = Server.CreateObject("MyComponent.MyClass") Currentreturn = MyVar.MyMethod If Currentreturn = False Response.Write(MyError) End If %>