[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Re: Why to use MarshalByRef

Sunny

7/13/2004 3:07:00 PM

Hi Shrine,



In article <6190C4B1-3087-4105-A4E3-A6D863F78ED5@microsoft.com>,
Shrine@discussions.microsoft.com says...
> Dear All,
> I am developing a .NET Remoting application. In my class, I am using
>
> Public Class ClassRemote
> Inherits MarshalByRef
>
> Can anyone please tell me, why I want to use MarshalByRef??
>

Actually you do not want to use it, but you have to if you want to use
remoting :).

MBR is special class, which makes it possible passing only a reference
to that object across application domain boundaries (I.e. marshal(pass)
by reference). That way not the object itself, but only reference (entry
point) to it is passed to the client, making remoting working.

MBR contains some specialized methods and internals, which control the
lifetime of the object, how it is connected to the remoting
infrastructure, etc.

Your remoting class has to inherit from MBR in order to be recognized
and maintained correctly by the system.

This is very simplified explanation, but it is good for start.

There is another type of remoting objects - these marshaled by value.
These classes are all other (not inherited from MBR), which can be
serialized, either marked as [Serializable], or implementing
ISerializable interface. These objects are serialized at the server and
their value is passed to the client. So client has a copy of the object
to work with. Any change to that copy, and every method executed in
these objects happens at client side. While when the object is MBR, all
the data and execution happens at the server, which is the main idea :)

Hope that helps

Cheers
Sunny

P.S. for a site, try this:
http://www.developer.com/net/net/article.p...