This paper is designed to give you a tour of .NET Remoting and its capabilities. The following topics are covered:
.NET Remoting is a new distributed component technology supported by the .NET framework. It enables .NET components in different Application Domains to communicate with each other. Application Domains cover more than just separate machines or process boundaries. They can provide isolation within the same process also.
.NET Remoting is built on the foundations of COM/DCOM, and can be seen as the next step in the evolution of distributed component technology.
.NET provides two technologies which may seem to make .NET remoting redundant: Web Services and Component Object Model (COM) interoperability.
Web Services is a new XML-based technology, designed to allow companies to provide interoperable services over the Internet. However, Web Services is not designed for tightly-coupled server-side integration between applications. .NET Remoting is more suitable for such integration for the following reasons:
COM interoperability refers to the ability of .NET components to communicate with legacy COM objects. This is very important for Microsoft as many application use COM technology. However, in the long term .NET remoting will replace COM functionality for new .NET applications as it has several advantages:
.NET remoting is configurable with XML configuration files or with a .NET API. An application's configuration information allows the user to:
When an application instantiates a class, the configuration is checked to see whether this class has been defined as a remote class. If it is a remote class then the construction and subsequent interaction with the object of the class is intercepted and marshalled over to the remote host defined by the configuration.
In addition to this, .NET remoting configuration files allow attributes of these remote and local objects to be specified, such as:
The above attributes are discussed in more detail in the following sections.
Channels refer to the transport protocol used to communicate with remote objects. Currently .NET remoting supports two channels, a TCP/IP channel and an HTTP channel. The ability for extra channels to be plugged in or for third parties to develop their own channels is available.
Formats refer to the format of the data sent across the wire. Currently .NET remoting supports binary format. As with channels, formats may be written and plugged in by third parties.
There are two basic modes of activation:
The client instantiates the remote object and receives an object reference to the object in response to its activation request. The client controls the lifetime of the object using leasing. The object reference can be passed onto other clients.
The server is responsible for the lifetime of the object. No object reference is returned to the client; in fact, no activation message is sent across the wire. Such server-activated objects require a parameterless constructor to be activated. Server activated objects may be activated once per application as Singletons or once per method invocation.
Knowing when to destroy an object that is referenced remotely is always a problem for distributed technologies. COM used reference counting to solve the distributed garbage collection. .NET remoting uses leasing. Using leasing, a remote object remains available for a configurable period of time before being destroyed. Leases may also configured to be extended when the object is accessed and also clients may be configured to be responsible for renewing leases before they expire.
Similarly, as J-Integra® for .NET adheres to the .NET Remoting standard, Java objects instanciated by .NET clients will follow the same leasing mechanism. For more details see Lifetime Management in J-Integra® for .NET.
As mentioned earlier, .NET remoting is seen to be a replacement for COM technology. At this time, COM is much more integrated into Windows Component Services than .NET remoting. However, going forward, .NET remoting will form the basis of Microsoft's distributed component technology and provide increased functionality and integration.