Export (0) Print
Expand All

RemotingConfiguration.RegisterActivatedClientType Method

Registers an object Type on the client end as a type that can be activated on the server.

Overload List

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

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

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

[Visual Basic] Overloads Public Shared Sub RegisterActivatedClientType(Type, String)
[C#] public static void RegisterActivatedClientType(Type, string);
[C++] public: static void RegisterActivatedClientType(Type*, String*);
[JScript] public static function RegisterActivatedClientType(Type, String);

Example

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

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of RegisterActivatedClientType. 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
Imports System.Runtime.Remoting.Channels.Tcp


Public Class ClientClass
   
   Public Shared Sub Main()
      
      ChannelServices.RegisterChannel(New TcpChannel())
      
      RemotingConfiguration.RegisterActivatedClientType(GetType(HelloServiceClass), "tcp://localhost:8082")
      
      Dim service As New HelloServiceClass()
      
      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;
using System.Runtime.Remoting.Channels.Tcp;

public class ClientClass {

    public static void Main() { 

        ChannelServices.RegisterChannel(new TcpChannel());

        RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                   "tcp://localhost:8082");

        HelloServiceClass service = new HelloServiceClass();

        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;
using namespace System::Runtime::Remoting::Channels::Tcp;

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

    RemotingConfiguration::RegisterActivatedClientType(__typeof(HelloServiceClass),
        S"tcp://localhost:8082");

    HelloServiceClass* service = new HelloServiceClass();

    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

Show:
© 2014 Microsoft