This topic has not yet been rated - Rate this topic

WellKnownServiceTypeEntry Class

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

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)
[ComVisibleAttribute(true)]
public class WellKnownServiceTypeEntry : TypeEntry

Server-activated object types can be either single call or singleton. If an object type is single call, a new instance of it is created each time a call from the client comes in. All calls to a singleton object are handled by one instance of that object.

Any client that knows the URI of this 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.

It is important to note that the remote object itself is not created by the registration process. This only happens when a client attempts to call a method on the object or activates the object from the client side.

For a more detailed description of server-activated objects and remote object activation, see [<topic://cpconActivation>].

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

public class MyServer 
{
   public static void Main() 
   {
      // Create a 'HttpChannel' object and register it with the  
      // channel services.
      ChannelServices.RegisterChannel(new HttpChannel(8086));
      // Record the 'HelloServer' type as 'Singleton' well-known type.
      WellKnownServiceTypeEntry myWellKnownServiceTypeEntry= 
          new WellKnownServiceTypeEntry(typeof(HelloServer),
                                        "SayHello",
                                        WellKnownObjectMode.Singleton);
      // Register the remote object as well-known type.
      RemotingConfiguration.RegisterWellKnownServiceType(
                                          myWellKnownServiceTypeEntry);
      // Retrieve object types registered on the service end  
      // as well-known types.
      WellKnownServiceTypeEntry [] myWellKnownServiceTypeEntryCollection = 
            RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
      Console.WriteLine("The 'WellKnownObjectMode' of the remote object : "
                       +myWellKnownServiceTypeEntryCollection[0].Mode);
      Console.WriteLine("The 'WellKnownServiceTypeEntry' object: "+
                  myWellKnownServiceTypeEntryCollection[0].ToString());
      Console.WriteLine("Started the Server, Hit <enter> to exit...");
      Console.ReadLine();
   }
}
#using <mscorlib.dll>
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <WellKnownServiceTypeEntry_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 it with the 
   // channel services.
   ChannelServices::RegisterChannel(new HttpChannel(8086));
   // Record the 'HelloServer' type as 'Singleton' well-known type.
   WellKnownServiceTypeEntry* myWellKnownServiceTypeEntry= 
      new WellKnownServiceTypeEntry(__typeof(HelloServer),
                                    S"SayHello",
                                    WellKnownObjectMode::Singleton);
   // Register the remote object as well-known type.
   RemotingConfiguration::RegisterWellKnownServiceType(myWellKnownServiceTypeEntry);
   // Retrieve object types registered on the service end 
   // as well-known types.
   WellKnownServiceTypeEntry* myWellKnownServiceTypeEntryCollection[] = 
      RemotingConfiguration::GetRegisteredWellKnownServiceTypes();
   Console::WriteLine(S"The 'WellKnownObjectMode' of the remote object : {0}", __box(myWellKnownServiceTypeEntryCollection[0]->Mode));
   Console::WriteLine(S"The 'WellKnownServiceTypeEntry' object: {0}", myWellKnownServiceTypeEntryCollection[0]);
   Console::WriteLine(S"Started the Server, Hit <enter> to exit...");
   Console::ReadLine();
}
System.Object
  System.Runtime.Remoting.TypeEntry
    System.Runtime.Remoting.WellKnownServiceTypeEntry
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.