Condividi tramite


RemotingConfiguration.RegisterWellKnownClientType Metodo

Definizione

Registra un oggetto Type sul lato client come tipo noto (singola chiamata o singleton).

Overload

Nome Descrizione
RegisterWellKnownClientType(WellKnownClientTypeEntry)

Registra un oggetto Type registrato nell'oggetto fornito WellKnownClientTypeEntry sul lato client come tipo noto che può essere attivato nel server.

RegisterWellKnownClientType(Type, String)

Registra un oggetto Type sul lato client come tipo noto che può essere attivato nel server, utilizzando i parametri specificati per inizializzare una nuova istanza della WellKnownClientTypeEntry classe .

RegisterWellKnownClientType(WellKnownClientTypeEntry)

Registra un oggetto Type registrato nell'oggetto fornito WellKnownClientTypeEntry sul lato client come tipo noto che può essere attivato nel server.

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)

Parametri

entry
WellKnownClientTypeEntry

Impostazioni di configurazione per il tipo noto.

Eccezioni

Almeno uno dei chiamanti più in alto nello stack di chiamate non dispone dell'autorizzazione per configurare tipi e canali remoti.

Commenti

Qualsiasi client che conosce l'URI di un oggetto noto registrato può ottenere un proxy per l'oggetto registrando il canale che preferisce con ChannelServicese attivando l'oggetto chiamando new o Activator.GetObject. Per attivare un oggetto noto con new, è prima necessario registrare il tipo di oggetto noto nel client usando il RegisterWellKnownClientType metodo . La chiamata al RegisterWellKnownClientType metodo fornisce all'infrastruttura remota la posizione dell'oggetto remoto, che consente alla new parola chiave di crearla. Se invece si usa il Activator.GetObject metodo per attivare l'oggetto noto, è necessario specificarlo con l'URL dell'oggetto come argomento, quindi non è necessaria alcuna registrazione precedente sul lato client.

Vedi anche

Si applica a

RegisterWellKnownClientType(Type, String)

Registra un oggetto Type sul lato client come tipo noto che può essere attivato nel server, utilizzando i parametri specificati per inizializzare una nuova istanza della 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)

Parametri

type
Type

TypeOggetto .

objectUrl
String

URL di un oggetto client noto.

Eccezioni

Almeno uno dei chiamanti più in alto nello stack di chiamate non dispone dell'autorizzazione per configurare tipi e canali remoti.

Esempio

Nell'esempio di codice seguente viene illustrata la registrazione di un tipo di oggetto sul lato client come tipo noto. Per il codice del server che corrisponde al codice client presentato, vedere l'esempio per il RegisterWellKnownServiceType metodo .

#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

Commenti

Qualsiasi client che conosce l'URI di un oggetto noto registrato può ottenere un proxy per l'oggetto registrando il canale che preferisce con ChannelServicese attivando l'oggetto chiamando new o Activator.GetObject. Per attivare un oggetto noto con new, è prima necessario registrare il tipo di oggetto noto nel client usando il RegisterWellKnownClientType metodo . La chiamata al RegisterWellKnownClientType metodo fornisce all'infrastruttura remota la posizione dell'oggetto remoto, che consente alla new parola chiave di crearla. Se invece si usa il Activator.GetObject metodo per attivare l'oggetto noto, è necessario specificarlo con l'URL dell'oggetto come argomento, quindi non è necessaria alcuna registrazione precedente sul lato client.

Vedi anche

Si applica a