June 6, 2007, 4:08 p.m.
posted by vendetta
Summary
The .NET Framework incorporates the concept of remoting, which allows applications to share methods between application domains, either on the same computer, or between separate computers on a network.
An important feature of remoting is the ability of a client to serialize class instances and pass them to a different application domain. The .NET library includes two serialization formatting classes, the BinaryFormatter and the SoapFormatter. Each of these classes can be used apart from remoting to help serialize data for transmission across a network connection.
While the BinaryFormatter and SoapFormatter classes help in the job of serializing data elements, you must still ensure all the data is properly sent across the network from the client to the server machines. You can incorporate techniques learned in Chapter 7 along with the serialization classes to ensure the data is properly delivered to the remote machine. By creating a separate buffer for the serialized data and sending the buffer size along with the buffer, you can ensure that the server receives the complete serialized data before attempting to deserialize the information.
The .NET remoting classes allow you to create a remote class whose methods can be accessed by any client on the network. The remote class must be derived from the MarshalByRefObject class to allow classes in remote application domains to access its methods and data elements.
For the client application to access the remote class, a proxy class must be created to accept method calls from the client, and pass them off to the remote class. The proxy class can be created either by the original data library of the remote class, or by interrogating the remote class using the soapsuds program. The soapsuds program allows you to determine the remote class interfaces necessary to properly access class methods without the original data class file.
The remote class must be registered in an application domain by a remoting server program. The remoting server registers the remote class within the .NET remoting system, along with a specific communication channel that can access the remote class. After all the pieces of the remoting system are in place, the client application can access methods in the remote class as if they were in the same application domain.
The next chapter dives into the sticky world of security within the .NET Framework. With the current emphasis on application security, Microsoft incorporated lots of security features with the .NET Framework that can be used in your C# network programs