This documentation is archived and is not being maintained.

RemotingConfiguration.RegisterWellKnownClientType Method (Type, String)

.NET Framework 1.1

Registers an object Type on the client end as a well-known type that can be activated on the server, using the given parameters to initialize a new instance of the WellKnownClientTypeEntry class.

[Visual Basic]
Overloads Public Shared Sub RegisterWellKnownClientType( _
   ByVal type As Type, _
   ByVal objectUrl As String _
)
[C#]
public static void RegisterWellKnownClientType(
 Type type,
 string objectUrl
);
[C++]
public: static void RegisterWellKnownClientType(
 Type* type,
 String* objectUrl
);
[JScript]
public static function RegisterWellKnownClientType(
   type : Type,
 objectUrl : String
);

Parameters

type
The object Type.
objectUrl
URL of a well-known client object.

Exceptions

Exception Type Condition
SecurityException At least one of the callers higher in the callstack does not have permission to configure Remoting types and channels.

Remarks

Any client that knows the URI of a registered well-known object can obtain a proxy for the object by registering the channel it prefers with ChannelServices, and activating the object by calling new or Activator.GetObject. To activate a well-known object with new, you must first register the well-known object type on the client using the RegisterWellKnownClientType method. Calling the RegisterWellKnownClientType method gives 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 the well-known object, you must supply it with the object's URL as an argument, so no prior registration on the client end is necessary.

For a detailed description of well-known objects see Server Activation.

Example

[Visual Basic, C#, C++] The following example demonstrates registration of an object type on the client end as a well-known type. For the server code that corresponds to the presented client code, see the example for the RegisterWellKnownServiceType method.

[Visual Basic] 
Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Tcp
Imports System.Runtime.Remoting.Channels


Public Class ClientClass
   
   
   Public Shared Sub Main()
      
    . . . 
      ChannelServices.RegisterChannel(New TcpChannel())
      
      RemotingConfiguration.RegisterWellKnownClientType(GetType(HelloService), "tcp://localhost:8082/HelloServiceApplication/MyUri")
      
      Dim service As New HelloService()
    . . . 

      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 'Main

End Class 'ClientClass

[C#] 
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels;


public class ClientClass {

    public static void Main() { 

    . . . 
        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterWellKnownClientType(
                                                           typeof(HelloService),
                                                           "tcp://localhost:8082/HelloServiceApplication/MyUri"
                                                         );

        HelloService service = new HelloService();
    . . . 

        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();
    }
}

[C++] 
#using <mscorlib.dll>
#using <system.dll>
#using <system.runtime.remoting.dll>

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


int main() 
{ 
    . . . 
    ChannelServices::RegisterChannel(new TcpChannel());

    RemotingConfiguration::RegisterWellKnownClientType(__typeof(HelloService),
        S"tcp://localhost:8082/HelloServiceApplication/MyUri");

    HelloService* service = new HelloService();
    . . . 

    if (service == 0) 
    {
        Console::WriteLine(S"Could not locate server.");
        return -1;
    }


    // Calls the remote method.
    Console::WriteLine();
    Console::WriteLine(S"Calling remote Object*");
    Console::WriteLine(service->HelloMethod(S"Caveman"));
    Console::WriteLine(service->HelloMethod(S"Spaceman"));
    Console::WriteLine(service->HelloMethod(S"Client Man"));
    Console::WriteLine(S"Finished remote Object* call");
    Console::WriteLine();

    return 0;
}

[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

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

.NET Framework Security: 

See Also

RemotingConfiguration Class | RemotingConfiguration Members | System.Runtime.Remoting Namespace | RemotingConfiguration.RegisterWellKnownClientType Overload List | WellKnownClientTypeEntry | WellKnownServiceTypeEntry

Show: