ComWrappers Classe

Definição

Importante

Esta API não está em conformidade com CLS.

Classe para gerenciar wrappers de tipos COM IUnknown.Class for managing wrappers of COM IUnknown types.

public ref class ComWrappers abstract
[System.CLSCompliant(false)]
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public abstract class ComWrappers
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
type ComWrappers = class
Public MustInherit Class ComWrappers
Herança
ComWrappers
Atributos

Comentários

A ComWrappers API fornece suporte para a IUnknown Abi, independentemente do suporte interno de interoperabilidade com.The ComWrappers API provides support for the IUnknown ABI, independent of the built-in COM interoperability support. A ComWrappers API expõe o suporte de tempo de execução mínimo necessário para que os desenvolvedores substituam a versão interna de maneira eficiente.The ComWrappers API exposes the minimal runtime support that's needed for developers to replace the built-in version in an efficient manner.

Tradicionalmente, no tempo de execução, um proxy nativo para um objeto gerenciado é chamado de CCW (COM Callable Wrapper), e um proxy gerenciado para um objeto nativo é chamado de RCW (Runtime Callable Wrapper).Traditionally in the runtime, a native proxy to managed object is called a COM Callable Wrapper (CCW), and a managed proxy to a native object is called a Runtime Callable Wrapper (RCW). No entanto, quando usado aqui, esses termos não devem ser confundidos com os recursos internos do mesmo nome (ou seja, CCW e RCW).However, when used here, those terms should not be confused with the built-in features of the same name (that is, CCW and RCW). Ao contrário dos recursos internos, a maior parte da responsabilidade pelo gerenciamento preciso do tempo de vida, métodos de expedição e marshalling de argumentos e valores de retorno é deixada para o ComWrappers implementador.Unlike the built-in features, a majority of the responsibility for accurate lifetime management, dispatching methods, and marshalling of arguments and return values is left to the ComWrappers implementer.

O "suporte mínimo" é definido pelos seguintes recursos:"Minimal support" is defined by the following features:

  1. Mapeamento eficiente entre um objeto gerenciado e um proxy nativo (por exemplo, CCW).Efficient mapping between a managed object and a native proxy (for example, CCW).

  2. Mapeamento eficiente entre um nativo IUnknown e seu proxy gerenciado (por exemplo, RCW).Efficient mapping between a native IUnknown and its managed proxy (for example, RCW).

  3. Integração com o coletor de lixo por meio do contrato de interface IReferenceTrackerHost .Integration with the garbage collector through the IReferenceTrackerHost interface contract.

    Aproveitar isso é um cenário avançado.Leveraging this is an advanced scenario.

Estado do proxyProxy state

Esta seção fornece descrições e ilustrações de estado de proxy nativo e gerenciado após sua respectiva criação.This section provides descriptions and illustrations of native and managed proxy state after their respective creation.

Nas ilustrações a seguir, uma referência forte é representada como uma linha sólida ( === ) e uma referência fraca é representada como uma linha tracejada ( = = = ).In the following illustrations, a strong reference is depicted as a solid line (===) and a weak reference is depicted as a dashed line (= = =). Os termos "referência forte" e "referência fraca" devem ser interpretados como "estendendo o tempo de vida" e "não estendendo o tempo de vida", em vez de implicar uma implementação específica.The terms "strong reference" and "weak reference" should be interpreted as "extending lifetime" and "not extending lifetime", as opposed to implying a specific implementation.

A ilustração a seguir mostra o estado do objeto gerenciado e o proxy nativo após uma chamada para ComWrappers.GetOrCreateComInterfaceForObject(Object, CreateComInterfaceFlags) .The following illustration shows the state of the managed object and native proxy after a call to ComWrappers.GetOrCreateComInterfaceForObject(Object, CreateComInterfaceFlags).

 --------------------                  ----------------------
|   Managed object   |                |     Native proxy     |
|                    |                | Ref count: 1         |
|  ----------------  |                |  ------------------  |
| | Weak reference |=| = = = = = = = >| | Strong reference | |
| |    to proxy    | |<===============|=|    to object     | |
|  ----------------  |                |  ------------------  |
 --------------------                  ----------------------

A ilustração a seguir mostra o estado do objeto nativo e o proxy gerenciado após uma chamada para ComWrappers.GetOrCreateObjectForComInstance(IntPtr, CreateObjectFlags) .The next illustration shows the state of the native object and managed proxy after a call to ComWrappers.GetOrCreateObjectForComInstance(IntPtr, CreateObjectFlags). O conceito de "identidade" segue as regras para IUnknown .The concept of "identity" follows the rules for IUnknown.

 ------------------               ------------------
|  Native object   |< = = = = = =|                  |
| Ref count: +1    |             | Mapping from     |
 ------------------              | native identity  |
 ------------------------        | to managed proxy |
|   Managed proxy        |< = = =|                  |
| Created by ComWrappers |        ------------------
|   implementer.         |
| Optional AddRef() on   |
|   native object.       |
 ------------------------

Observe que há apenas referências fracas existentes da perspectiva de tempo de execução.Observe that only weak references exist from the runtime perspective. Pressupõe-se que a +1 contagem de referência no objeto nativo seja executada pelo criador de proxy gerenciado (ou seja, o ComWrappers implementador) para garantir o tempo de vida associado entre o objeto nativo e seu proxy gerenciado.The +1 reference count on the native object is assumed to be performed by the managed proxy creator (that is, the ComWrappers implementer) to ensure the associated lifetime between the native object and its managed proxy. Há uma referência forte opcional (ou seja, AddRef() ) mencionada no proxy gerenciado, que é usada para dar suporte ao cenário (3) mencionado anteriormente.There is an optional strong reference (that is, AddRef()) mentioned in the managed proxy, which is used to support scenario (3) mentioned earlier. Consulte CreateObjectFlags.TrackerObject.See CreateObjectFlags.TrackerObject. Com essa referência forte opcional, a contagem de referência seria +2 .With this optional strong reference, the reference count would be +2.

Construtores

ComWrappers()

Construtor da instância.Instance constructor.

Métodos

ComputeVtables(Object, CreateComInterfaceFlags, Int32)

Computa a Vtable desejada para obj, respeitando os valores de flags.Computes the desired Vtable for obj, respecting the values of flags.

CreateObject(IntPtr, CreateObjectFlags)

Cria um objeto gerenciado para o objeto para o qual externalComObject aponta, respeitando os valores de flags.Creates a managed object for the object that externalComObject points to, respecting the values of flags.

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetIUnknownImpl(IntPtr, IntPtr, IntPtr)

Obtém a implementação IUnknown fornecida pelo runtime.Gets the runtime-provided IUnknown implementation.

GetOrCreateComInterfaceForObject(Object, CreateComInterfaceFlags)

Cria uma representação COM do objeto fornecido que pode ser passado para um ambiente não gerenciado.Creates a COM representation of the supplied object that can be passed to a non-managed environment.

GetOrCreateObjectForComInstance(IntPtr, CreateObjectFlags)

Obtém o objeto gerenciado atualmente registrado ou cria um objeto gerenciado e o registra.Gets the currently registered managed object or creates a new managed object and registers it.

GetOrRegisterObjectForComInstance(IntPtr, CreateObjectFlags, Object)

Obtém o objeto gerenciado atualmente registrado ou usa o objeto gerenciado fornecido e o registra.Gets the currently registered managed object or uses the supplied managed object and registers it.

GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
RegisterForMarshalling(ComWrappers)

Registra uma instância de ComWrappers a ser usada como a instância global para realizar marshaling no runtime.Registers a ComWrappers instance to be used as the global instance for marshalling in the runtime.

RegisterForTrackerSupport(ComWrappers)

Registra uma instância de ComWrappers a ser usada como a instância global para suporte ao controlador de referência.Registers a ComWrappers instance to be used as the global instance for reference tracker support.

ReleaseObjects(IEnumerable)

Libera uma coleção de objetos fora do objeto normal ou do tempo de vida da interface COM.Releases a collection of objects outside of the normal object or COM interface lifetime.

ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a