PrimaryInteropAssemblyAttribute PrimaryInteropAssemblyAttribute PrimaryInteropAssemblyAttribute PrimaryInteropAssemblyAttribute Class

定义

指示该特性化的程序集是主互操作程序集。Indicates that the attributed assembly is a primary interop assembly.

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

注解

您可以将此特性应用于程序集,虽然Tlbimp.exe (类型库导入程序)通常为您应用导入类型库时。You can apply this attribute to assemblies, although the Tlbimp.exe (Type Library Importer) typically applies it for you when it imports a type library.

互操作程序集包含描述了现有的 COM 类型,通常已在 COM 类型库中的所述的元数据。An interop assembly contains metadata that describes existing COM types, which are often already described in a COM type library. Tlbimp.exe 生成从 COM 类型库的互操作程序集。Tlbimp.exe produces interop assemblies from COM type libraries. 互操作程序集通常仅包含元数据 (无代码)。Interop assemblies typically only contain metadata (no code). 它们描述,并提供与该类型库定义的类型的正式定义的类型库相同的发布者提供主互操作程序集。Primary interop assemblies are provided by the same publisher as the type library they describe, and provide the official definitions of the types defined with that type library. 其发布服务器始终签名主互操作程序集以确保唯一性。Primary interop assemblies are always signed by their publisher to ensure uniqueness.

按以下方式,可以从类型库生成主互操作程序集:You can generate a primary interop assembly from a type library in the following ways:

若要在托管的源代码中指定主互操作程序集,必须应用System.Runtime.InteropServices.GuidAttributePrimaryInteropAssemblyAttribute对在设计时程序集。To specify a primary interop assembly in managed source code, you must apply the System.Runtime.InteropServices.GuidAttribute and PrimaryInteropAssemblyAttribute to the assembly at design time. GuidAttribute上的主互操作程序集标识的类型库的 LIBID 和PrimaryInteropAssemblyAttribute标识为其此程序集是主互操作程序集的特定类型库版本。The GuidAttribute on the primary interop assembly identifies the LIBID of the type library and the PrimaryInteropAssemblyAttribute identifies the version of the particular type library for which this assembly is the primary interop assembly. PrimaryInteropAssemblyAttribute可以出现多次,如果程序集相同的类型库的多个版本的主互操作程序集。The PrimaryInteropAssemblyAttribute can appear multiple times if the assembly is the primary interop assembly for multiple versions of the same type library.

使用类型库中定义类型时,始终引用该类型库,而不是重新导入或重新定义这些类型本身的主互操作程序集。When using the types defined in a type library, always reference the primary interop assembly for that type library, rather than reimporting or redefining the types themselves. 有关指导原则和过程如何生成或使用主互操作程序集,请参阅Primary Interop AssembliesFor guidelines and procedures on how to produce or use primary interop assemblies, see Primary Interop Assemblies. 类型库导入进程的详细说明,请参阅类型库到程序集转换摘要For a detailed description of the type library importing process, see Type Library to Assembly Conversion Summary.

构造函数

PrimaryInteropAssemblyAttribute(Int32, Int32) PrimaryInteropAssemblyAttribute(Int32, Int32) PrimaryInteropAssemblyAttribute(Int32, Int32) PrimaryInteropAssemblyAttribute(Int32, Int32)

使用类型库(此程序集是该类型库的主互操作程序集)的主版本号及次版本号初始化 PrimaryInteropAssemblyAttribute 类的新实例。Initializes a new instance of the PrimaryInteropAssemblyAttribute class with the major and minor version numbers of the type library for which this assembly is the primary interop assembly.

属性

MajorVersion MajorVersion MajorVersion MajorVersion

获取程序集是其主互操作程序集的类型库的主版本号。Gets the major version number of the type library for which this assembly is the primary interop assembly.

MinorVersion MinorVersion MinorVersion MinorVersion

获取程序集是其主互操作程序集的类型库的次版本号。Gets the minor version number of the type library for which this assembly is the primary interop assembly.

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)

适用于

另请参阅