Type.IsEquivalentTo(Type) Type.IsEquivalentTo(Type) Type.IsEquivalentTo(Type) Type.IsEquivalentTo(Type) Method


确定两个 COM 类型是否具有相同的标识,以及是否符合类型等效的条件。Determines whether two COM types have the same identity and are eligible for type equivalence.

 virtual bool IsEquivalentTo(Type ^ other);
public virtual bool IsEquivalentTo (Type other);
abstract member IsEquivalentTo : Type -> bool
override this.IsEquivalentTo : Type -> bool
Public Overridable Function IsEquivalentTo (other As Type) As Boolean


Type Type Type Type

要测试是否与当前类型等效的 COM 类型。The COM type that is tested for equivalence with the current type.


如果 COM 类型等效,则为 true;否则为 falsetrue if the COM types are equivalent; otherwise, false. 如果一个类型位于为执行加载的程序集中,而另一个类型位于已加载到仅限反射上下文的程序集中,则此方法也返回 falseThis method also returns false if one type is in an assembly that is loaded for execution, and the other is in an assembly that is loaded into the reflection-only context.


从开始,公共语言运行时支持直接将 com 类型的类型信息嵌入到托管程序集中,而不需要托管程序集从互操作获取 com 类型的类型信息.NET Framework 4.NET Framework 4程序.Beginning with the .NET Framework 4.NET Framework 4, the common language runtime supports the embedding of type information for COM types directly into managed assemblies, instead of requiring the managed assemblies to obtain type information for COM types from interop assemblies. 由于嵌入式类型信息仅包含托管程序集实际使用的类型和成员,因此两个托管程序集可能具有相同 COM 类型的不同视图。Because the embedded type information includes only the types and members that are actually used by a managed assembly, two managed assemblies might have very different views of the same COM type. 每个托管程序集都有不同的 Type 对象来表示其 COM 类型视图。Each managed assembly has a different Type object to represent its view of the COM type. 公共语言运行时支持接口、结构、枚举和委托等不同视图之间的类型等效性。The common language runtime supports type equivalence between these different views for interfaces, structures, enumerations, and delegates.

类型等效性意味着从一个托管程序集传递到另一个托管程序集的 COM 对象可以转换为接收程序集中适当的托管类型。Type equivalence means that a COM object that is passed from one managed assembly to another can be cast to the appropriate managed type in the receiving assembly. IsEquivalentTo方法使程序集能够确定从另一个程序集获取的 com 对象与第一个程序集自己的嵌入互操作类型之一具有相同的 com 标识,因此可以强制转换为该类型。The IsEquivalentTo method enables an assembly to determine that a COM object obtained from another assembly has the same COM identity as one of the first assembly's own embedded interop types, and thus can be cast to that type.

有关详细信息,请参阅类型等效性和嵌入的互操作类型For more information, see Type Equivalence and Embedded Interop Types.