WellKnownClientTypeEntry Classe

Définition

Contient les valeurs d'un type d'objet inscrit sur le client en tant que type activé par le serveur (appel simple ou singleton).

public ref class WellKnownClientTypeEntry : System::Runtime::Remoting::TypeEntry
public class WellKnownClientTypeEntry : System.Runtime.Remoting.TypeEntry
[System.Runtime.InteropServices.ComVisible(true)]
public class WellKnownClientTypeEntry : System.Runtime.Remoting.TypeEntry
type WellKnownClientTypeEntry = class
    inherit TypeEntry
[<System.Runtime.InteropServices.ComVisible(true)>]
type WellKnownClientTypeEntry = class
    inherit TypeEntry
Public Class WellKnownClientTypeEntry
Inherits TypeEntry
Héritage
WellKnownClientTypeEntry
Attributs

Exemples

#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <WellKnownClientTypeEntry_Share.dll>

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Http;

int main()
{
   // Create a 'HttpChannel' object and  register with channel services.
   ChannelServices::RegisterChannel( gcnew HttpChannel );
   Console::WriteLine( " Start calling from Client One......." );
   WellKnownClientTypeEntry^ myWellKnownClientTypeEntry = gcnew WellKnownClientTypeEntry( HelloServer::typeid,"http://localhost:8086/SayHello" );
   myWellKnownClientTypeEntry->ApplicationUrl = "http://localhost:8086/SayHello";
   RemotingConfiguration::RegisterWellKnownClientType( myWellKnownClientTypeEntry );

   // Get the proxy object for the remote object.
   HelloServer^ myHelloServerObject = gcnew HelloServer;

   // Retrieve an array of object types registered on the 
   // client end as well-known types.
   array<WellKnownClientTypeEntry^>^myWellKnownClientTypeEntryCollection = RemotingConfiguration::GetRegisteredWellKnownClientTypes();
   Console::WriteLine( "The Application Url to activate the Remote Object :{0}", myWellKnownClientTypeEntryCollection[ 0 ]->ApplicationUrl );
   Console::WriteLine( "The 'WellKnownClientTypeEntry' object :{0}", myWellKnownClientTypeEntryCollection[ 0 ] );

   // Make remote method calls.
   for ( int i = 0; i < 5; i++ )
      Console::WriteLine( myHelloServerObject->HelloMethod( " Client One" ) );
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class MyClient 
{
   public static void Main()
   {
   // Create a 'HttpChannel' object and  register with channel services.
   ChannelServices.RegisterChannel(new HttpChannel());
   Console.WriteLine(" Start calling from Client One.......");
   WellKnownClientTypeEntry myWellKnownClientTypeEntry = 
                  new WellKnownClientTypeEntry(typeof(HelloServer),
                                  "http://localhost:8086/SayHello");
   myWellKnownClientTypeEntry.ApplicationUrl="http://localhost:8086/SayHello";
   RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry);
   // Get the proxy object for the remote object.
   HelloServer myHelloServerObject = new HelloServer();
   // Retrieve an array of object types registered on the 
   // client end as well-known types.
   WellKnownClientTypeEntry [] myWellKnownClientTypeEntryCollection = 
          RemotingConfiguration.GetRegisteredWellKnownClientTypes();
   Console.WriteLine("The Application Url to activate the Remote Object :"
        +myWellKnownClientTypeEntryCollection[0].ApplicationUrl);
   Console.WriteLine("The 'WellKnownClientTypeEntry' object :"
            +myWellKnownClientTypeEntryCollection[0].ToString());
   // Make remote method calls.
   for (int i = 0; i < 5; i++)
         Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"));
   }
}
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.Http

Public Class MyClient
   
   Public Shared Sub Main()
      ' Create a 'HttpChannel' object and  register with channel services.
      ChannelServices.RegisterChannel(New HttpChannel())
      Console.WriteLine(" Start calling from Client One.......")
      Dim myWellKnownClientTypeEntry As New WellKnownClientTypeEntry(GetType(HelloServer), _ 
                                                  "http://localhost:8086/SayHello")
      myWellKnownClientTypeEntry.ApplicationUrl = "http://localhost:8086/SayHello"
      RemotingConfiguration.RegisterWellKnownClientType(myWellKnownClientTypeEntry)
      ' Get the proxy object for the remote object.
      Dim myHelloServerObject As New HelloServer()
      ' Retrieve an array of object types registered on the 
      ' client end as well-known types.
      Dim myWellKnownClientTypeEntryCollection As WellKnownClientTypeEntry() = _ 
                                       RemotingConfiguration.GetRegisteredWellKnownClientTypes()
      Console.WriteLine("The Application Url to activate the Remote Object :" + _ 
                                           myWellKnownClientTypeEntryCollection(0).ApplicationUrl)
      Console.WriteLine("The 'WellKnownClientTypeEntry' object :" + _ 
                                              myWellKnownClientTypeEntryCollection(0).ToString())
      ' Make remote method calls.
      Dim i As Integer
      For i = 0 To 4
         Console.WriteLine(myHelloServerObject.HelloMethod(" Client One"))
      Next i
   End Sub
End Class

Remarques

Les types activés par le serveur peuvent être un seul appel ou singleton. Si une classe est inscrite en tant que type d’appel unique, une nouvelle instance est créée chaque fois qu’un appel du client arrive. Tous les appels à un objet singleton sont gérés par un instance de cet objet, sauf si cet objet a été collecté.

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

Pour obtenir une description détaillée des objets activés par le serveur et de l’activation d’objets distants, consultez Activation d’objets distants.

Constructeurs

WellKnownClientTypeEntry(String, String, String)

Initialise une nouvelle instance de la classe WellKnownClientTypeEntry avec le type, le nom d'assembly et l'URL donnés.

WellKnownClientTypeEntry(Type, String)

Initialise une nouvelle instance de la classe WellKnownClientTypeEntry avec l'URL et le type donnés.

Propriétés

ApplicationUrl

Obtient ou définit l'URL de l'application dans laquelle le type doit être activé.

AssemblyName

Obtient le nom d'assembly du type d'objets configuré pour être un type activé à distance.

(Hérité de TypeEntry)
ObjectType

Obtient le Type du type de clients activé par le serveur.

ObjectUrl

Obtient l'URL de l'objet client activé par le serveur.

TypeName

Obtient le nom complet du type d'objets configuré pour être un type activé à distance.

(Hérité de TypeEntry)

Méthodes

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
ToString()

Retourne le nom complet de type, le nom d'assembly et l'URL d'objet du type de clients activé par le serveur sous la forme de String.

S’applique à

Voir aussi