3个回答
展开全部
1. Import a type library as an assembly
COM的类型定义通常在type library(tlb)中,与之对应的是CLS兼容的编译器在assembly中产生类型元数据(type metadata),这两种类型信息的来源有很大的不同
Generating Metadata
COM的类型库(type libraries)可以是一个单独得Tlb文件,例如Loanlib.tlb。一些类型库被嵌入到DLL或者Exe的资源文件中,还有一些类型库在OLB或者OCX中。
找到包含你的COM类型的类型库之后,可以有以下的选择来生成包含元数据的交互程序集(interop assembly)
Option Description
Visual Studio .NET Automatically converts COM types in a type library to metadata in an assembly.
Type Library Importer Provides command-line switches to adjust metadata in the resulting interop file, imports types from an existing type library, and generates an interop assembly and a namespace.
TypeLibConverter Class Exposes methods that perform conversion-related actions. Can convert in-memory type library information to metadata.
Custom Wrappers As a less desirable option, you can create type definitions from scratch. This requires advanced programming skills.
Visual Studio .NET
当添加一个给定的type library 的引用(reference)时,Visual Studio .NET生成包含元数据的交互程序集(interop assembly)。如果一个主交互程序集(primary interop assembly)有效的话,Visual Studio使用存在的assembly
To add a reference to a type library
1. Install the COM DLL or EXE file on your computer, unless a Windows Setup.exe performs the installation for you.
2. From the Project menu, select References.
3. Select the COM tab.
4. Select the type library from the Available References list, or browse for the TLB file.
5. Click OK.
COM的类型定义通常在type library(tlb)中,与之对应的是CLS兼容的编译器在assembly中产生类型元数据(type metadata),这两种类型信息的来源有很大的不同
Generating Metadata
COM的类型库(type libraries)可以是一个单独得Tlb文件,例如Loanlib.tlb。一些类型库被嵌入到DLL或者Exe的资源文件中,还有一些类型库在OLB或者OCX中。
找到包含你的COM类型的类型库之后,可以有以下的选择来生成包含元数据的交互程序集(interop assembly)
Option Description
Visual Studio .NET Automatically converts COM types in a type library to metadata in an assembly.
Type Library Importer Provides command-line switches to adjust metadata in the resulting interop file, imports types from an existing type library, and generates an interop assembly and a namespace.
TypeLibConverter Class Exposes methods that perform conversion-related actions. Can convert in-memory type library information to metadata.
Custom Wrappers As a less desirable option, you can create type definitions from scratch. This requires advanced programming skills.
Visual Studio .NET
当添加一个给定的type library 的引用(reference)时,Visual Studio .NET生成包含元数据的交互程序集(interop assembly)。如果一个主交互程序集(primary interop assembly)有效的话,Visual Studio使用存在的assembly
To add a reference to a type library
1. Install the COM DLL or EXE file on your computer, unless a Windows Setup.exe performs the installation for you.
2. From the Project menu, select References.
3. Select the COM tab.
4. Select the type library from the Available References list, or browse for the TLB file.
5. Click OK.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询