Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WellKnownClientTypeEntry Class

Holds values for an object type registered on the client as a server-activated type (single call or singleton).

For a list of all members of this type, see WellKnownClientTypeEntry Members.

System.Object
   System.Runtime.Remoting.TypeEntry
      System.Runtime.Remoting.WellKnownClientTypeEntry

[Visual Basic]
Public Class WellKnownClientTypeEntry
   Inherits TypeEntry
[C#]
public class WellKnownClientTypeEntry : TypeEntry
[C++]
public __gc class WellKnownClientTypeEntry : public TypeEntry
[JScript]
public class WellKnownClientTypeEntry extends TypeEntry

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

Server-activated types can be either single call or singleton. If a class is registered as a single call type, a new instance is created each time a call from the client arrives. All calls to a singleton object are handled by one instance of that object, unless that object has been collected.

Any client that knows the URI of a registered server-activated object can obtain a proxy for this object by registering the channel it prefers with ChannelServices and activating the object by calling new or Activator.GetObject. To activate a server-activated object with new, you must first register the server-activated object type on the client using the RegisterWellKnownClientType method. By calling RegisterWellKnownClientType, you are giving the remoting infrastructure the location of the remote object, which allows the new keyword to create it. If, on the other hand, you use the Activator.GetObject method to activate a server-activated object, you must supply it with the object's URL as an argument, so no prior registration on the client is necessary.

For a detailed description of server-activated objects and remote object activation, see Activation.

Example

[Visual Basic] 
Imports System
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 'Main
End Class 'MyClient 

[C#] 
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"));
   }
}

[C++] 
#using <mscorlib.dll>
#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(new HttpChannel());
   Console::WriteLine(S" Start calling from Client One.......");
   WellKnownClientTypeEntry* myWellKnownClientTypeEntry = 
      new WellKnownClientTypeEntry(__typeof(HelloServer),
      S"http://localhost:8086/SayHello");
   myWellKnownClientTypeEntry->ApplicationUrl=S"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(S"The Application Url to activate the Remote Object :{0}", myWellKnownClientTypeEntryCollection[0]->ApplicationUrl);
   Console::WriteLine(S"The 'WellKnownClientTypeEntry' object :{0}", myWellKnownClientTypeEntryCollection[0]);
   // Make remote method calls.
   for (int i = 0; i < 5; i++)
      Console::WriteLine(myHelloServerObject->HelloMethod(S" Client One"));
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Runtime.Remoting

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

WellKnownClientTypeEntry Members | System.Runtime.Remoting Namespace | RegisterWellKnownClientType | Server Activation

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.