This post provides you the overview of .NET Remoting Framework. It allows the objects to interact with one another across the application domains.
- Communication channels for transporting messages across applications
- Formatters are used for encoding and decoding the messages. supported formatters are
1. Binary encoding formatter – use when performance is critical
2. XML encoding formatter = use when Interoperability is essential
- Object activation and life-time support
Object activation model falls into two categories
An object is consider to be remote when the caller of the object is in different application domain. Object has to decorate with [serializable] custom attribute or they have to implement ISerializable interface to be considered as a remote. Remote objects have to be passed by value. Any object can be changed to remote by deriving from MarshalByRefObject.
Proxy Objects are created when client activates a remote object. Proxy object acts as a representative to remote object and ensures that all calls that made on proxy are forwarded to the remote object.
Two types of Proxy Objects
when client activates a remote object, Framework creates a local instance of TransparentProxy class. All method calls on Transparent Proxy object are intercepted by CLR and forwards the call if the remote object is in same application domain.
Real Proxy object calls are intercepted by CLR and forwards the call even the remote object is in different application domain by calling its Invoke method.
channels are used to transport message to and from the remote objects.
- Channels must be registered with the framework before a remote object can be called.
- Channels are registered per application domain.
- Clients can communicate with a remote object by calling RegisterChannel on the ChannelService class.
The HTTP channel transports the messages to remote objects using SOAP formatter. All messages are changed in to XML and serialized when it is using SOAP Formatter.
The TCP channel uses binary formatter to transport the messages to remote objects.
Remoting framework supports server and client activation of remote objects.
Server activation can be used when there is no need to maintain the state between the method calls.
Client activation objects are instantiated from the client, and manages the life time of the remote object.
Registering a channel
Activating the object
HelloServer obj = (HelloServer)Activator.GetObject(