RemotingConfiguration.RegisterActivatedClientType Method (Type, String)

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.

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.RemotingConfiguration)]
public static void RegisterActivatedClientType(
	Type type,
	string appUrl
)

Parameters

type
Type: System.Type

The object Type.

appUrl
Type: System.String

URL of the application where this type is activated.

ExceptionCondition
ArgumentNullException

The typeName or URI parameter is null.

SecurityException

At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.

To create an instance of a client-activated object on the server, you must know its Type and it must be registered on the server end by using the RegisterActivatedServiceType method. To obtain a proxy for a new instance of the client-activated object, the client must first register a channel with ChannelServices and then activate the object by calling new.

To activate a client-activated object type with the new keyword, you must first register the object type on the client end using the RegisterActivatedClientType method. Calling the RegisterActivatedClientType method gives the remoting infrastructure the location of the remote application where new attempts to create it. If, on the other hand, you use the Activator.CreateInstance method to create a new instance of the client-activated object, you must supply the remote application's URL as a parameter, so no prior registration on the client end is necessary. To supply the Activator.CreateInstance method with the URL of the server where you want to create the object, you must encapsulate the URL in an instance of the UrlAttribute class.

For a detailed description of client-activated objects, see [<topic://cpconClientActivation>]

The following code 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.

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");

        try
        {
            HelloServiceClass service = new HelloServiceClass();


           // 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();
        }
	catch (Exception ex)
	{
	   Console.WriteLine("An exception occured: " + ex.Message);
        }
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft