13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

When to Marshal by ValueSo how do you know when MBV is a good option? Let's say that MBV is a compell<strong>in</strong>goption when the follow<strong>in</strong>g conditions are true:• The object is not particularly large and complex.• You're go<strong>in</strong>g to make <strong>in</strong>tensive use of the object.• You have no special security concerns.• The object has no dependencies on remote resources such as files,databases, devices, or system resources.Some rather illustrious .<strong>NET</strong> Framework classes that support remot<strong>in</strong>g through theMBV technique are the DataSet and DataTable classes.MBV ObjectsThe .<strong>NET</strong> Remot<strong>in</strong>g system serializes all the <strong>in</strong>ternal data of MBV objects and passesthe stream to the call<strong>in</strong>g AppDoma<strong>in</strong>, as illustrated <strong>in</strong> Figure 12-2.Figure 12-2: How .<strong>NET</strong> Remot<strong>in</strong>g marshals objects by value.After the data is <strong>in</strong> the client AppDoma<strong>in</strong>, a new local object is <strong>in</strong>stantiated and<strong>in</strong>itialized and starts handl<strong>in</strong>g calls. To write remotable objects that are exchanged byvalue, you need to make them serializable, either by declar<strong>in</strong>g the SerializableAttributeattribute or by implement<strong>in</strong>g ISerializable. Aside from this, noth<strong>in</strong>g else is required <strong>for</strong><strong>in</strong>stances of the class to be passed by value across AppDoma<strong>in</strong>s.Marshal<strong>in</strong>g Objects by ReferenceWhen an object is marshaled by reference, the client process receives a reference tothe server-side object, rather than a copy. This means that any call directed to theobject is always resolved on the server with<strong>in</strong> the native context of the object. Theremot<strong>in</strong>g <strong>in</strong>frastructure governs the call, collect<strong>in</strong>g all <strong>in</strong><strong>for</strong>mation about the call andsend<strong>in</strong>g it to the server process. On the server, the correct object is located and askedto execute the call us<strong>in</strong>g the client's arguments. When the call is f<strong>in</strong>ished, the resultsare packaged and sent back to the client. Unlike MBV, MBR uses the network only <strong>for</strong>transmitt<strong>in</strong>g arguments and return values. Figure 12-3 shows the architecture of MBRremot<strong>in</strong>g.429

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!