TypeLibVersionAttribute TypeLibVersionAttribute TypeLibVersionAttribute TypeLibVersionAttribute Class

定义

指定已导出类型库的版本号。Specifies the version number of an exported type library.

public ref class TypeLibVersionAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class TypeLibVersionAttribute : Attribute
type TypeLibVersionAttribute = class
    inherit Attribute
Public NotInheritable Class TypeLibVersionAttribute
Inherits Attribute
继承
TypeLibVersionAttributeTypeLibVersionAttributeTypeLibVersionAttributeTypeLibVersionAttribute
属性

示例

下面的示例演示如何应用TypeLibVersionAttribute显式将类型库版本设置为 1.25。The following example shows how to apply the TypeLibVersionAttribute to explicitly set the type library version to 1.25.

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

[assembly: AssemblyVersion("1.2.500.0")];
[assembly: TypeLibVersion(1,25)];
namespace MyNamespace
{
    public ref class TheClass
    {
        // Insert code.
    };
};
using System;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("1.2.500.0")]
[assembly: TypeLibVersion(1,25)]
namespace MyNamespace
{
    public class TheClass
    {
        // Insert code.
    }
}
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

<Assembly: AssemblyVersion("1.2.500.0")>
<Assembly: TypeLibVersion(1,25)>
Namespace MyNamespace
    Public Class TheClass
        ' Insert code.
    End Class
End Namespace

注解

您可以将此特性应用于程序集。You can apply this attribute to assemblies.

默认情况下Tlbexp.exe (类型库导出程序)从程序集版本的前两个数字生成类型库版本。By default, the Tlbexp.exe (Type Library Exporter) generates a type library version from the first two numbers of an assembly version. 例如,Tlb.exe 将程序集版本 1.2.5000.0 作为类型库版本 1.2,消除了程序集的内部版本号和修订号。For example, Tlb.exe exports assembly version 1.2.5000.0 as a type library version 1.2, eliminating the build and revision numbers of the assembly. 如果不需要此行为,则可以通过应用显式控制生成的类型库号TypeLibVersionAttributeIf this behavior is undesirable, you can control the generation of the type library number explicitly by applying the TypeLibVersionAttribute.

它可用于在两个程序集版本生成的相同的类型库版本时显式控制生成的类型库版本。It is useful to control the generation of a type library version explicitly when two assembly versions produce the same type library version. 例如,程序集版本 1.2.0.0 和程序集版本 1.2.500.0 这两个生成类型库版本为 1.2,当你卸载某个程序集时可能会导致问题。For example, assembly version 1.2.0.0 and assembly version 1.2.500.0 both produce a type library version of 1.2, which can cause problems when you uninstall one of the assemblies. 若要区分类型库版本,您可以强制的第二个程序集 (版本 1.2.500.0) 以生成 1.25 的类型库版本。To differentiate the type library versions, you can force the second assembly (version 1.2.500.0) to produce a type library version of 1.25.

构造函数

TypeLibVersionAttribute(Int32, Int32) TypeLibVersionAttribute(Int32, Int32) TypeLibVersionAttribute(Int32, Int32) TypeLibVersionAttribute(Int32, Int32)

使用类型库的主版本号和次版本号初始化 TypeLibVersionAttribute 类的新实例。Initializes a new instance of the TypeLibVersionAttribute class with the major and minor version numbers of the type library.

属性

MajorVersion MajorVersion MajorVersion MajorVersion

获取类型库的主版本号。Gets the major version number of the type library.

MinorVersion MinorVersion MinorVersion MinorVersion

获取类型库的次版本号。Gets the minor version number of the type library.

TypeId TypeId TypeId TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

适用于

另请参阅