TypeLibrary Declarations

It is very common for ActiveX components to describe any constants that the component supports in a type library. A type library is a file that contains information about objects and types supported by an ActiveX component. If your Web application relies on ActiveX objects that have declared data types in type libraries, you can declare the type libraries in Global.asa. Doing so will make it possible to refer to the data types 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

Syntax

<!--METADATA TYPE="TypeLib"
FILE="file"
UUID="typelibraryuuid"
VERSION="majorversionnumber.minorversionnumber"
LCID="localeid"
-->

Parameters

file
Absolute path to a type library. If this parameter and the typelibraryuuid parameter are provided, file is used to identify the type library. Either the file parameter or the typelibraryuuid parameter is required.
typelibraryuuid
Universally unique identifer for the type library. Either the file parameter or the typelibraryuuid parameter is required.
majorversionnumber
Used for selecting version. If the requested version is not found, then an error is returned (optional).
minorversionnumber
Used for selecting version. If the requested version is not found, then an error is returned (optional).
localeid
The locale identifier to be used for the type library. If the requested locale is not found, then an error is returned (optional)

Error Values

The server can return one of the following error messages.

Error Description
ASP 0222 Invalid type library specification. The METADATA tag contains an invalid type library specification.
ASP 0223 Type library not found. The METADATA tag contains a type library specification that does not match any registry entry.
ASP 0224 Type library cannot be loaded. ASP cannot load the type library specified in the METADATA tag.
ASP 0225 Type library cannot be wrapped. ASP cannot create a Type Library Wrapper object from the type libraries specified in the METADATA tag.

Remarks

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 will include the optional STARTSPAN and ENDSPAN keywords. These keywords are ignored by IIS.

Example

MyComponent in the following example was developed with Visual Basic 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 you have installed in the following directory.

C:\MyComponent

The following METADATA tag is included in the global.asa file for the MyApp application. This example uses the optional STARTSPAN and ENDSPAN tags. These tags are not required by IIS.

<!--METADATA TYPE="TypeLib"
FILE="MyComponent.lib"
-->
 

Any ASP 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
%>