Compartir a través de


TypeLibrary Declarations

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.

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 identifier 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, the most recent version is used (optional).

  • minorversionnumber
    Used for selecting version. If the requested version is not found, the most recent version is used (optional).

  • localeid
    The locale identifier to be used for the type library. If the requested locale is not found, the system locale identifier is used (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 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.

Example Code

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

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS