TypeLibVersionAttribute 类

指定导出类型库的版本号。

**命名空间:**System.Runtime.InteropServices
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Assembly, Inherited:=False)> _
Public NotInheritable Class TypeLibVersionAttribute
    Inherits Attribute
用法
Dim instance As TypeLibVersionAttribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false)] 
public sealed class TypeLibVersionAttribute : Attribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets::Assembly, Inherited=false)] 
public ref class TypeLibVersionAttribute sealed : public Attribute
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false) */ 
public final class TypeLibVersionAttribute extends Attribute
ComVisibleAttribute(true) 
AttributeUsageAttribute(AttributeTargets.Assembly, Inherited=false) 
public final class TypeLibVersionAttribute extends Attribute

备注

可以将此属性应用到程序集。

默认情况下,类型库导出程序 (Tlbexp.exe) 从程序集版本的前两个数字生成类型库版本。例如,Tlb.exe 将程序集版本 1.2.5000.0 导出为类型库版本 1.2,去掉了程序集的内部版本号和修订号。如果这不是所需的行为,则可应用 TypeLibVersionAttribute 显式控制类型库版本号的生成。

当两个程序集版本将生成相同的类型库版本时,显式控制类型库版本的生成会很有用。例如,程序集版本 1.2.0.0 和程序集版本 1.2.500.0 都会生成类型库版本 1.2,这将在卸载其中一个程序集时造成问题。为区分类型库版本,可强制使第二个程序集(版本 1.2.500.0)生成类型库版本 1.25。

示例

下面的示例说明如何应用 TypeLibVersionAttribute 将类型库版本显式设置为 1.25。

Imports System
 Imports System.Runtime.Interop
 <Assembly: AssemblyVersion ("1.2.500.0")>
 <Assembly: TypeLibVersionAttribute(1,25)>
 Module MyNamespace
   Public Class c
     ' Insert code.
   End Class
using System;
 using System.Runtime.InteropServices;
 [Assembly: AssemblyVersion ("1.2.500.0")>
 [Assembly: TypeLibVersion(1,25)]
 namespace MyNamespace
 {
   class MyClass
   {
     // Insert code.
   }
 }

继承层次结构

System.Object
   System.Attribute
    System.Runtime.InteropServices.TypeLibVersionAttribute

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1

请参见

参考

TypeLibVersionAttribute 成员
System.Runtime.InteropServices 命名空间

其他资源

类型库导出程序 (Tlbexp.exe)