Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 1.1
.NET Framework
Reference
Methods
This page is specific to
Microsoft Visual Studio 2003/.NET Framework 1.1

Other versions are also available for the following:
.NET Framework Class Library
RemotingConfiguration.RegisterWellKnownClientType Method

Registers an object Type on the client end as a well-known type (single call or singleton).

Overload List

Registers an object Type recorded in the provided WellKnownClientTypeEntry on the client end as a well-known type that can be activated on the server.

[Visual Basic] Overloads Public Shared Sub RegisterWellKnownClientType(WellKnownClientTypeEntry)
[C#] public static void RegisterWellKnownClientType(WellKnownClientTypeEntry);
[C++] public: static void RegisterWellKnownClientType(WellKnownClientTypeEntry*);
[JScript] public static function RegisterWellKnownClientType(WellKnownClientTypeEntry);

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(Type, String)
[C#] public static void RegisterWellKnownClientType(Type, string);
[C++] public: static void RegisterWellKnownClientType(Type*, String*);
[JScript] public static function RegisterWellKnownClientType(Type, String);

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, C#, C++] Note   This example shows how to use one of the overloaded versions of RegisterWellKnownClientType. For other examples that might be available, see the individual overload topics.
[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.

See Also

RemotingConfiguration Class | RemotingConfiguration Members | System.Runtime.Remoting Namespace

© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker