ServicedComponent Classe
Definição
Representa a classe base de todas as classes usando serviços COM+.Represents the base class of all classes using COM+ services.
public ref class ServicedComponent abstract : ContextBoundObject, IDisposable, System::EnterpriseServices::IRemoteDispatch, System::EnterpriseServices::IServicedComponentInfo
[System.Serializable]
public abstract class ServicedComponent : ContextBoundObject, IDisposable, System.EnterpriseServices.IRemoteDispatch, System.EnterpriseServices.IServicedComponentInfo
[<System.Serializable>]
type ServicedComponent = class
inherit ContextBoundObject
interface IRemoteDispatch
interface IDisposable
interface IServicedComponentInfo
Public MustInherit Class ServicedComponent
Inherits ContextBoundObject
Implements IDisposable, IRemoteDispatch, IServicedComponentInfo
- Herança
- Derivado
- Atributos
- Implementações
Exemplos
O exemplo de código a seguir demonstra como expor uma classe como um componente COM configurado.The following code example demonstrates how to expose a class as a configured COM component.
[assembly:ApplicationName("Calculator")];
[assembly:ApplicationActivation(ActivationOption::Library)];
[assembly:System::Reflection::AssemblyKeyFile("Calculator.snk")];
public ref class Calculator: public ServicedComponent
{
public:
int Add( int x, int y )
{
return (x + y);
}
};
using System;
using System.EnterpriseServices;
[assembly: ApplicationName("Calculator")]
[assembly: ApplicationActivation(ActivationOption.Library)]
[assembly: System.Reflection.AssemblyKeyFile("Calculator.snk")]
public class Calculator : ServicedComponent
{
public int Add (int x, int y)
{
return(x+y);
}
}
Para implantar essa classe como um componente COM configurado, você deve gerar uma chave forte, compilar a classe como uma biblioteca e registrar a biblioteca.To deploy this class as a configured COM component, you must generate a strong key, compile the class as a library, and register the library. Essas três etapas são realizadas com os três comandos a seguir.These three steps are accomplished by the following three commands.
sn -k Calculator.snk
csc /t:library Calculator.cs
regsvcs Calculator.dll
Comentários
Em determinadas condições, uma classe derivada da que é ServicedComponent executada em um aplicativo com+ pode parar de responder.Under certain conditions, a class that is derived from ServicedComponent that runs in a COM+ application may stop responding. Esse problema é causado por um deadlock de atividade.This problem is caused by an Activity deadlock. As atividades podem deadlock em aplicativos multithread devido a uma limpeza assíncrona de referências de componente.Activities can deadlock on multithreaded applications because of an asynchronous cleanup of component references. Para contornar esse problema, chame o Dispose método quando concluir o trabalho com objetos derivados de ServicedComponent .To work around this problem, call the Dispose method when you complete work with objects derived from ServicedComponent.
Observação
O código do cliente deve chamar Dispose em componentes de serviço para garantir a operação adequada.Client code must call Dispose on serviced components to ensure proper operation.
Construtores
| ServicedComponent() |
Inicializa uma nova instância da classe ServicedComponent.Initializes a new instance of the ServicedComponent class. |
Métodos
| Activate() |
Chamado pela infraestrutura quando o objeto é criado ou alocado de um pool.Called by the infrastructure when the object is created or allocated from a pool. Substitua este método para adicionar código de inicialização personalizada aos objetos.Override this method to add custom initialization code to objects. |
| CanBePooled() |
Este método é chamado pela infraestrutura antes que o objeto seja colocado de volta no pool.This method is called by the infrastructure before the object is put back into the pool. Substitua este método para votar se o objeto deve ser colocado de volta no pool.Override this method to vote on whether the object is put back into the pool. |
| Construct(String) |
Chamado pela infraestrutura logo após o construtor ser chamado, passando a cadeia de caracteres do construtor.Called by the infrastructure just after the constructor is called, passing in the constructor string. Substitua este método para fazer uso do valor da cadeia de caracteres de construção.Override this method to make use of the construction string value. |
| CreateObjRef(Type) |
Cria um objeto que contém todas as informações relevantes necessárias para gerar um proxy usado para se comunicar com um objeto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Herdado de MarshalByRefObject) |
| Deactivate() |
Chamado pela infraestrutura quando o objeto está prestes a ser desativado.Called by the infrastructure when the object is about to be deactivated. Substitua este método para adicionar código de finalização personalizado a objetos quando o código compilado JIT (Just-In-Time) ou o pool de objetos for usado.Override this method to add custom finalization code to objects when just-in-time (JIT) compiled code or object pooling is used. |
| Dispose() |
Libera todos os recursos usados pelo ServicedComponent.Releases all resources used by the ServicedComponent. |
| Dispose(Boolean) |
Libera os recursos não gerenciados usados pelo ServicedComponent e opcionalmente libera os recursos gerenciados.Releases the unmanaged resources used by the ServicedComponent and optionally releases the managed resources. |
| DisposeObject(ServicedComponent) |
Finaliza o objeto e remove a referência de COM+ associada.Finalizes the object and removes the associated COM+ reference. |
| 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) |
| GetLifetimeService() |
Obsoleto.
Recupera o objeto de serviço de tempo de vida atual que controla a política de ciclo de vida para esta instância.Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Herdado de MarshalByRefObject) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| InitializeLifetimeService() |
Obsoleto.
Obtém um objeto de serviço de tempo de vida para controlar a política de tempo de vida para essa instância.Obtains a lifetime service object to control the lifetime policy for this instance. (Herdado de MarshalByRefObject) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| MemberwiseClone(Boolean) |
Cria uma cópia superficial do objeto MarshalByRefObject atual.Creates a shallow copy of the current MarshalByRefObject object. (Herdado de MarshalByRefObject) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |
Implantações explícitas de interface
| IRemoteDispatch.RemoteDispatchAutoDone(String) |
Esta API dá suporte à infraestrutura do produto e não deve ser usada diretamente do seu código. Garante que, no contexto COM+, o bit |
| IRemoteDispatch.RemoteDispatchNotAutoDone(String) |
Não garante que, no contexto COM+, o bit |
| IServicedComponentInfo.GetComponentInfo(Int32, String[]) |
Obtém determinadas informações sobre a instância da classe ServicedComponent.Obtains certain information about the ServicedComponent class instance. |