Introduction
This post provides you the overview of .NET Remoting Framework. It allows the objects to interact with one another across the application domains.
Features
- 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
1.Client-activated objects
2.Server-activated objects
Remote Objects
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
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
1.Transparent Proxy
2.Real Proxy
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
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.
HTTP Channel
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.
TCP Channel
The TCP channel uses binary formatter to transport the messages to remote objects.
Activation
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
Example:
RemotingConfiguration.RegisterWellKnownServiceType(
Type.GetType("RemotingConsole.HelloServer,object"),
"Hello server",
WellKnownObjectMode.SingleCall);
}
Activating the object
Example:
HelloServer obj = (HelloServer)Activator.GetObject(
typeof(RemotingConsole.HelloServer),
"tcp://localhost:8085/SayHello");
Remoting overview…
You’ve been kicked (a good thing) – Trackback from DotNetKicks.com…
[…] Remoting is distributed application technology built in the Framework 2.0 with new features which allows the developer to build wide range of distributed applications. Overview of Remoting. […]