WellKnownClientTypeEntry Klasa

Definicja

Przechowuje wartości typu obiektu zarejestrowanego na kliencie jako typ aktywowany przez serwer (pojedyncze wywołanie lub pojedyncze).

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
Dziedziczenie
WellKnownClientTypeEntry
Atrybuty

Przykłady

#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

Uwagi

Typy aktywowane przez serwer mogą być pojedynczym wywołaniem lub pojedynczym wywołaniem. Jeśli klasa jest zarejestrowana jako pojedynczy typ wywołania, nowe wystąpienie jest tworzone za każdym razem, gdy zostanie odebrane wywołanie klienta. Wszystkie wywołania pojedynczego obiektu są obsługiwane przez jedno wystąpienie tego obiektu, chyba że ten obiekt został zebrany.

Każdy klient, który zna identyfikator URI zarejestrowanego obiektu aktywowanego przez serwer, może uzyskać serwer proxy dla tego obiektu, rejestrując preferowany kanał ChannelServices i uaktywniając obiekt przez wywołanie new metody lub Activator.GetObject. Aby aktywować obiekt newaktywowany przez serwer za pomocą polecenia , należy najpierw zarejestrować typ obiektu aktywowanego przez serwer na kliencie przy użyciu RegisterWellKnownClientType metody . Wywołując RegisterWellKnownClientTypemetodę , udostępniasz infrastrukturze komunikacji zdalnej lokalizację obiektu zdalnego, dzięki czemu słowo kluczowe może new go utworzyć. Jeśli z drugiej strony używasz Activator.GetObject metody do aktywowania obiektu aktywowanego przez serwer, musisz podać go jako argument jako argument, więc nie jest wymagana wcześniejsza rejestracja na kliencie.

Aby uzyskać szczegółowy opis obiektów aktywowanych przez serwer i aktywacji obiektów zdalnych, zobacz Aktywacja obiektów zdalnych.

Konstruktory

WellKnownClientTypeEntry(String, String, String)

Inicjuje WellKnownClientTypeEntry nowe wystąpienie klasy przy użyciu danego typu, nazwy zestawu i adresu URL.

WellKnownClientTypeEntry(Type, String)

Inicjuje WellKnownClientTypeEntry nowe wystąpienie klasy o danym typie i adresie URL.

Właściwości

ApplicationUrl

Pobiera lub ustawia adres URL aplikacji, aby aktywować typ.

AssemblyName

Pobiera nazwę zestawu typu obiektu skonfigurowanego jako typ aktywowany zdalnie.

(Odziedziczone po TypeEntry)
ObjectType

Type Pobiera typ klienta aktywowanego przez serwer.

ObjectUrl

Pobiera adres URL obiektu klienta aktywowanego przez serwer.

TypeName

Pobiera pełną nazwę typu obiektu skonfigurowanego jako typ aktywowany zdalnie.

(Odziedziczone po TypeEntry)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca pełną nazwę typu, nazwę zestawu i adres URL obiektu typu klienta aktywowanego przez serwer jako String.

Dotyczy

Zobacz też