Developing an Application That Uses .NET Remoting

When developing an application that uses .NET Remoting, three steps are required to get the communication up and running:

  1. Create the server component The server component will offer a number of methods that can be called (by reference) and some type of data that will be passed to and returned by these methods (by value). Classes on the server component must implement the MarshalByRefObject interface to allow communication via .NET Remoting. Any data to be passed by value must also be serializable.

  2. Create the client The client application calling the server component doesn't need to implement any additional interfaces to enable .NET Remoting, but it does need a reference to the server component assembly or the interface itself. This reference is used to interrogate the methods and data types that are exposed by the server component.

  3. Configure the Remoting.Config file You have two options for configuring a system that uses .NET Remoting. The configuration which includes the reference to the remote systems, channels, and formatters that will be usedcan be stored either in the code or in a configuration file that's accessed at run time.

One advantage of storing the configuration in a configuration file is that the values in the configuration file can be changed without recompiling the application. This means that if the configuration of distributed components in a production environment change or if another channel is required (for example, because of the implementation of a firewall), you can make these configurations on the fly. Storing the configuration in code still works, but it means that any changes will require the component to be recompiled and potentially redeployed.

Fortunately, in .NET, the structure of the remoting.config file is fairly simple. Here's a sample:

 <configuration>     <system.runtime.remoting>         <application>                 <client url="tcp://localhost:8888/URL">                 <activated type="Namespace.Class, AssemblyName"/>             </client>         </application>     </system.runtime.remoting> </configuration> 

In addition to recognizing that the file is written in XML, you can see that the main configuration lies within the < client > element tags in the file. The attribute in the < client > element specifies the URL for the endpoint of the server component, and within the server component, the activated types are specified. These are the classes to be called by reference.

Microsoft. NET and J2EE Interoperability Toolkit
Microsoft .NET and J2EE Interoperability Toolkit (Pro-Developer)
ISBN: 0735619220
EAN: 2147483647
Year: 2003
Pages: 132
Authors: Simon Guest © 2008-2017.
If you may any questions please contact us: