RemotingConfiguration.RegisterWellKnownClientType Método

Definição

Registra um objeto Type na extremidade do cliente como um tipo conhecido (chamada única ou singleton).

Sobrecargas

Nome Description
RegisterWellKnownClientType(WellKnownClientTypeEntry)

Registra um objeto Type registrado no final do cliente fornecido WellKnownClientTypeEntry como um tipo conhecido que pode ser ativado no servidor.

RegisterWellKnownClientType(Type, String)

Registra um objeto Type na extremidade do cliente como um tipo conhecido que pode ser ativado no servidor, usando os parâmetros fornecidos para inicializar uma nova instância da WellKnownClientTypeEntry classe.

RegisterWellKnownClientType(WellKnownClientTypeEntry)

Registra um objeto Type registrado no final do cliente fornecido WellKnownClientTypeEntry como um tipo conhecido que pode ser ativado no servidor.

public:
 static void RegisterWellKnownClientType(System::Runtime::Remoting::WellKnownClientTypeEntry ^ entry);
public static void RegisterWellKnownClientType(System.Runtime.Remoting.WellKnownClientTypeEntry entry);
static member RegisterWellKnownClientType : System.Runtime.Remoting.WellKnownClientTypeEntry -> unit
Public Shared Sub RegisterWellKnownClientType (entry As WellKnownClientTypeEntry)

Parâmetros

entry
WellKnownClientTypeEntry

Configurações para o tipo conhecido.

Exceções

Pelo menos um dos chamadores mais altos na caixa de chamadas não tem permissão para configurar tipos e canais de comunicação remota.

Comentários

Qualquer cliente que conheça o URI de um objeto conhecido registrado pode obter um proxy para o objeto registrando o canal com ChannelServiceso qual ele prefere e ativando o objeto chamando new ou Activator.GetObject. Para ativar um objeto conhecido com new, primeiro você deve registrar o tipo de objeto conhecido no cliente usando o RegisterWellKnownClientType método. Chamar o RegisterWellKnownClientType método fornece à infraestrutura de comunicação remota o local do objeto remoto, o que permite que a new palavra-chave o crie. Se, por outro lado, você usar o Activator.GetObject método para ativar o objeto conhecido, deverá fornecê-lo com a URL do objeto como argumento, portanto, nenhum registro prévio no final do cliente será necessário.

Confira também

Aplica-se a

RegisterWellKnownClientType(Type, String)

Registra um objeto Type na extremidade do cliente como um tipo conhecido que pode ser ativado no servidor, usando os parâmetros fornecidos para inicializar uma nova instância da WellKnownClientTypeEntry classe.

public:
 static void RegisterWellKnownClientType(Type ^ type, System::String ^ objectUrl);
public static void RegisterWellKnownClientType(Type type, string objectUrl);
static member RegisterWellKnownClientType : Type * string -> unit
Public Shared Sub RegisterWellKnownClientType (type As Type, objectUrl As String)

Parâmetros

type
Type

O objeto Type.

objectUrl
String

URL de um objeto cliente conhecido.

Exceções

Pelo menos um dos chamadores mais altos na caixa de chamadas não tem permissão para configurar tipos e canais de comunicação remota.

Exemplos

O exemplo de código a seguir demonstra o registro de um tipo de objeto na extremidade do cliente como um tipo conhecido. Para o código do servidor que corresponde ao código do cliente apresentado, consulte o exemplo do RegisterWellKnownServiceType método.

#using <system.dll>
#using <system.runtime.remoting.dll>
#using "service.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels::Tcp;
using namespace System::Runtime::Remoting::Channels;
int main()
{
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;

public class ClientClass {

    public static void Main() {
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Channels


Public Class ClientClass
   
   
   Public Shared Sub Main()
ChannelServices::RegisterChannel( gcnew TcpChannel );
RemotingConfiguration::RegisterWellKnownClientType( HelloService::typeid,
                                                    "tcp://localhost:8082/HelloServiceApplication/MyUri" );
HelloService ^ service = gcnew HelloService;
ChannelServices.RegisterChannel(new TcpChannel());

RemotingConfiguration.RegisterWellKnownClientType(
                                                   typeof(HelloService),
                                                   "tcp://localhost:8082/HelloServiceApplication/MyUri"
                                                 );

HelloService service = new HelloService();
ChannelServices.RegisterChannel(New TcpChannel())

RemotingConfiguration.RegisterWellKnownClientType(GetType(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri")

Dim service As New HelloService()
   if ( service == nullptr )
   {
      Console::WriteLine( "Could not locate server." );
      return  -1;
   }

   // Calls the remote method.
   Console::WriteLine();
   Console::WriteLine( "Calling remote Object*" );
   Console::WriteLine( service->HelloMethod( "Caveman" ) );
   Console::WriteLine( service->HelloMethod( "Spaceman" ) );
   Console::WriteLine( service->HelloMethod( "Client Man" ) );
   Console::WriteLine( "Finished remote Object* call" );
   Console::WriteLine();
   return 0;
}

        if(service == null) {
            Console.WriteLine("Could not locate server.");
            return;
        }

        // Calls the remote method.
        Console.WriteLine();
        Console.WriteLine("Calling remote object");
        Console.WriteLine(service.HelloMethod("Caveman"));
        Console.WriteLine(service.HelloMethod("Spaceman"));
        Console.WriteLine(service.HelloMethod("Client Man"));
        Console.WriteLine("Finished remote object call");
        Console.WriteLine();
    }
}

      If service Is Nothing Then
         Console.WriteLine("Could not locate server.")
         Return
      End If
            
      ' Calls the remote method.
      Console.WriteLine()
      Console.WriteLine("Calling remote object")
      Console.WriteLine(service.HelloMethod("Caveman"))
      Console.WriteLine(service.HelloMethod("Spaceman"))
      Console.WriteLine(service.HelloMethod("Client Man"))
      Console.WriteLine("Finished remote object call")
      Console.WriteLine()

   End Sub

End Class

Comentários

Qualquer cliente que conheça o URI de um objeto conhecido registrado pode obter um proxy para o objeto registrando o canal com ChannelServiceso qual ele prefere e ativando o objeto chamando new ou Activator.GetObject. Para ativar um objeto conhecido com new, primeiro você deve registrar o tipo de objeto conhecido no cliente usando o RegisterWellKnownClientType método. Chamar o RegisterWellKnownClientType método fornece à infraestrutura de comunicação remota o local do objeto remoto, o que permite que a new palavra-chave o crie. Se, por outro lado, você usar o Activator.GetObject método para ativar o objeto conhecido, deverá fornecê-lo com a URL do objeto como argumento, portanto, nenhum registro prévio no final do cliente será necessário.

Confira também

Aplica-se a