|
|||||
|
Remoting makes an object in one process (called the server) available to code in other process (called the client). This is called marshalling. There are fundamentally two different ways to marshal an object: Marshal by value: the server creates a copy of the object and passes the copy to the client. The client can then use the object's data and functionality directly within its own process. Marshal by reference: the client creates a proxy for the object and then uses the proxy to access the object. The .NET framework creates a proxy in the client's application domain and the client uses that proxy to access the original object on the server. Given the differences between MBV and MBR, how does one decide which to use when programming a remotable class? In some situations you have no choice other than to use MBR, such as when the remote component must run in its own original application domain, in order to access local files or use operating system handles. These operations cannot be carried out by a copy of the object running in the client's application domain. You would also need to use MBR when the client should be made aware of changes in the object. However, in situations where both work, ask yourself which technique places fewer demands on the transport between server and client? With MBV you need move the object copy from the server to the client one time. While this can be a heavy thing to do with large objects, after the copy is at the client, calls to it are within the client's application domain, and thus, do not involve the transport mechanism at all. In short, small objects that the application accesses frequently are best remoted using MBV. Large objects that the application accesses relatively infrequently should be remoted using MBR. You might want to do some performance testing with both the options to get an insight into the decision.
|