Partage via


RemotingConfiguration.RegisterWellKnownClientType Méthode

Définition

Inscrit un objet Type à la fin du client en tant que type connu (appel unique ou singleton).

Surcharges

Nom Description
RegisterWellKnownClientType(WellKnownClientTypeEntry)

Inscrit un objet enregistré dans l’objet Type fourni WellKnownClientTypeEntry à la fin du client en tant que type connu qui peut être activé sur le serveur.

RegisterWellKnownClientType(Type, String)

Inscrit un objet Type à la fin du client en tant que type connu qui peut être activé sur le serveur, à l’aide des paramètres donnés pour initialiser une nouvelle instance de la WellKnownClientTypeEntry classe.

RegisterWellKnownClientType(WellKnownClientTypeEntry)

Inscrit un objet enregistré dans l’objet Type fourni WellKnownClientTypeEntry à la fin du client en tant que type connu qui peut être activé sur le serveur.

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)

Paramètres

entry
WellKnownClientTypeEntry

Paramètres de configuration pour le type connu.

Exceptions

Au moins un des appelants plus haut dans la pile d’appels n’est pas autorisé à configurer les types et canaux de communication à distance.

Remarques

Tout client qui connaît l’URI d’un objet bien connu inscrit peut obtenir un proxy pour l’objet en inscrivant le canal avec lequel il préfère ChannelServices, et en activant l’objet en appelant new ou Activator.GetObject. Pour activer un objet connu avec new, vous devez d’abord inscrire le type d’objet connu sur le client à l’aide de la RegisterWellKnownClientType méthode. L’appel de la RegisterWellKnownClientType méthode donne à l’infrastructure de communication à distance l’emplacement de l’objet distant, ce qui permet au new mot clé de le créer. Si, d’autre part, vous utilisez la Activator.GetObject méthode pour activer l’objet bien connu, vous devez le fournir avec l’URL de l’objet en tant qu’argument, donc aucune inscription préalable à la fin du client n’est nécessaire.

Voir aussi

S’applique à

RegisterWellKnownClientType(Type, String)

Inscrit un objet Type à la fin du client en tant que type connu qui peut être activé sur le serveur, à l’aide des paramètres donnés pour initialiser une nouvelle instance de la 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)

Paramètres

type
Type

TypeObjet .

objectUrl
String

URL d’un objet client connu.

Exceptions

Au moins un des appelants plus haut dans la pile d’appels n’est pas autorisé à configurer les types et canaux de communication à distance.

Exemples

L’exemple de code suivant illustre l’inscription d’un type d’objet sur la fin du client en tant que type connu. Pour le code serveur qui correspond au code client présenté, consultez l’exemple de méthode RegisterWellKnownServiceType .

#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

Remarques

Tout client qui connaît l’URI d’un objet bien connu inscrit peut obtenir un proxy pour l’objet en inscrivant le canal avec lequel il préfère ChannelServices, et en activant l’objet en appelant new ou Activator.GetObject. Pour activer un objet connu avec new, vous devez d’abord inscrire le type d’objet connu sur le client à l’aide de la RegisterWellKnownClientType méthode. L’appel de la RegisterWellKnownClientType méthode donne à l’infrastructure de communication à distance l’emplacement de l’objet distant, ce qui permet au new mot clé de le créer. Si, d’autre part, vous utilisez la Activator.GetObject méthode pour activer l’objet bien connu, vous devez le fournir avec l’URL de l’objet en tant qu’argument, donc aucune inscription préalable à la fin du client n’est nécessaire.

Voir aussi

S’applique à