ClassInterfaceType ClassInterfaceType ClassInterfaceType ClassInterfaceType Enum

Definición

Identifica el tipo de interfaz de clase que se genera para una clase.Identifies the type of class interface that is generated for a class.

public enum class ClassInterfaceType
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum ClassInterfaceType
type ClassInterfaceType = 
Public Enum ClassInterfaceType
Herencia
ClassInterfaceTypeClassInterfaceTypeClassInterfaceTypeClassInterfaceType
Atributos

Campos

AutoDispatch AutoDispatch AutoDispatch AutoDispatch 1

Indica que la clase sólo admite enlaces en tiempo de ejecución para los clientes COM.Indicates that the class only supports late binding for COM clients. Si se solicita, se expone automáticamente a los clientes COM una interfaz dispinterface para la clase.A dispinterface for the class is automatically exposed to COM clients on request. La biblioteca de tipos creada por Tlbexp.exe (exportador de la biblioteca de tipos) no contiene información de tipos para la interfaz dispinterface con el fin de impedir que los clientes almacenen en memoria caché los DISPID de la interfaz.The type library produced by Tlbexp.exe (Type Library Exporter) does not contain type information for the dispinterface in order to prevent clients from caching the DISPIDs of the interface. La interfaz dispinterface no presenta los problemas de control de versiones descritos en ClassInterfaceAttribute, ya que los clientes solo se pueden enlazar a la interfaz en tiempo de ejecución.The dispinterface does not exhibit the versioning problems described in ClassInterfaceAttribute because clients can only late-bind to the interface.

Esta es la configuración predeterminada de ClassInterfaceAttribute.This is the default setting for ClassInterfaceAttribute.

AutoDual AutoDual AutoDual AutoDual 2

Indica que se genera una interfaz de clase dual para la clase y se expone a COM automáticamente.Indicates that a dual class interface is automatically generated for the class and exposed to COM. Se genera la información de tipos para la interfaz de clase y se publica en la biblioteca de tipos.Type information is produced for the class interface and published in the type library. Se desaconseja el uso de AutoDual debido a las limitaciones de las versiones descritas en ClassInterfaceAttribute.Using AutoDual is strongly discouraged because of the versioning limitations described in ClassInterfaceAttribute.

None None None None 0

Indica que no se genera ninguna interfaz de clase para la clase.Indicates that no class interface is generated for the class. Si no se implementan interfaces explícitamente, la clase solo proporcionará acceso de enlace en tiempo de ejecución a través de la interfaz IDispatch.If no interfaces are implemented explicitly, the class can only provide late-bound access through the IDispatch interface. Éste es el valor recomendado para ClassInterfaceAttribute.This is the recommended setting for ClassInterfaceAttribute. La utilización de ClassInterfaceType.None es la única manera de exponer funcionalidad a través de interfaces implementadas explícitamente por la clase.Using ClassInterfaceType.None is the only way to expose functionality through interfaces implemented explicitly by the class.

Ejemplos

En este ejemplo se muestra cómo aplicar ClassInterfaceAttribute a un tipo, ClassInterfaceTypeestableciendo.This example shows how to apply the ClassInterfaceAttribute to a type, setting the ClassInterfaceType. Las clases definidas de esta manera se pueden usar desde COM no administrado.Classes defined this way can be used from unmanaged COM.

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

// Have the CLR expose a class interface (derived from IDispatch)
// for this type. COM clients can call the  members of this
// class using the Invoke method from the IDispatch interface.
[ClassInterface(ClassInterfaceType::AutoDispatch)]
public ref class AClassUsableViaCOM
{
public:
    AClassUsableViaCOM() 
    { 
    }

public:
    int Add(int x, int y)
    {
        return x + y;
    }
};

// The CLR does not expose a class interface for this type.
// COM clients can call the members of this class using
// the methods from the IComparable interface.
[ClassInterface(ClassInterfaceType::None)]
public ref class AnotherClassUsableViaCOM : public IComparable
{
public:
    AnotherClassUsableViaCOM() 
    { 
    }

    virtual int CompareTo(Object^ o) = IComparable::CompareTo
    {
        return 0;
    }
};
using System;
using System.Runtime.InteropServices;

// Have the CLR expose a class interface (derived from IDispatch) for this type.
// COM clients can call the  members of this class using the Invoke method from the IDispatch interface.
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class AClassUsableViaCOM
{
    public AClassUsableViaCOM() { }

    public Int32 Add(Int32 x, Int32 y) { return x + y; }
}

// The CLR does not expose a class interface for this type.
// COM clients can call the members of this class using the methods from the IComparable interface.
[ClassInterface(ClassInterfaceType.None)]
public class AnotherClassUsableViaCOM : IComparable
{
    public AnotherClassUsableViaCOM() { }

    Int32 IComparable.CompareTo(Object o) { return 0; }
}
Imports System
Imports System.Runtime.InteropServices


' Have the CLR expose a class interface (derived from IDispatch) for this type.
' COM clients can call the  members of this class using the Invoke method from the IDispatch interface.
<ClassInterface(ClassInterfaceType.AutoDispatch)> _
Public Class AClassUsableViaCOM

    Public Sub New()

    End Sub

    Public Function Add(ByVal x As Int32, ByVal y As Int32) As Int32
        Return x + y

    End Function
End Class
' The CLR does not expose a class interface for this type.
' COM clients can call the members of this class using the methods from the IComparable interface.
<ClassInterface(ClassInterfaceType.None)> _
Public Class AnotherClassUsableViaCOM
    Implements IComparable

    Public Sub New()

    End Sub

    Function CompareTo(ByVal o As [Object]) As Int32 Implements IComparable.CompareTo
        Return 0

    End Function 'IComparable.CompareTo
End Class

Comentarios

Esta enumeración se utiliza junto con el ClassInterfaceAttribute atributo.This enumeration is used in conjunction with the ClassInterfaceAttribute attribute.

Se aplica a

Consulte también: