Client Activation

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the  Windows Communication Foundation (WCF).

Client-activated objects are objects whose lifetimes are controlled by the calling application domain, just as they would be if the object were local to the client. When a client activated object is created, the client makes a call to the server. The server instantiates the remote object and returns an object reference (ObjRef) back to the client. The client uses that ObjRef to create a proxy to the remote object. Each time a client creates an instance of a client activated object, it receives a proxy that communicates with a specific server instance of the remote object until its lease expires and its memory is recycled.

In COM, clients keep an object in memory by maintaining a reference to it. When the last client releases its last reference, the object can delete itself. Client activation provides the same client control over the server object's lifetime, but without the complexity of maintaining references or the constant pinging to confirm the continued existence of the server or client. Instead, client-activated objects use lifetime leases to determine how long they should continue to exist. When a client creates a remote object, it can specify a default length of time that the object should exist. If the remote object reaches its default lifetime limit, it contacts the client to ask whether it should continue to exist, and if so, for how much longer. If the client is not currently available, a default time is also specified for how long the server object should wait while trying to contact the client before marking itself for garbage collection. The client might even request an indefinite default lifetime, effectively preventing the remote object from ever being recycled until the server application domain is torn down. The difference between this and a server-activated indefinite lifetime is that an indefinite server-activated object serves all client requests for that type, whereas the client-activated instances serve only the client and the reference that was responsible for their creation. For more information, see Lifetime Leases.

To create an instance of a client-activated type, clients either configure their application programmatically (or using a configuration file) and call new (New in Visual Basic), or they pass the remote object's configuration in a call to Activator.CreateInstance.

For information about how to create an instance of a client-activated type see, How To: Create an Instance of a Client-Activated Type.

For information about how to use a configuration file to configure a host application to create client-activated types, see <activated> Element (Service Instance). For information about how to use a configuration file to configure a client to use client-activated types, see <activated> Element (Client Instance).

See Also

Tasks

How to: Create an Instance of a Client-Activated Type

Concepts

Activation of Remote Objects
Configuration of Remote Applications
Server Activation
Lifetime Leases