You need to look at the broader picture. Where does MarshalByRefObject get
used? In scenarios like cross appdomain/process/machine method calls, you
need a mechanism for transforming your stack based method call into some
transportable format, transport the call, then transforming it back into
stack based method calls in or on the target appdomain/process/machine, and
the same back again. This is where the transparent proxy, real proxy and
MarshalByRefObject objects come into the picture. In order for the
transparent proxy to intercept all calls there needs to made sure that no
inlining takes place. How could the transparent proxy transform a method
call and send it to the real proxy if the JIT compiler inlined the method?
It is here that MarshalByRefObject comes to the rescue. To ensure that all
method calls are intercepted by the transparent proxy you inherit from
MarshalByRefObject. Hope this makes things clearer.
Regards
Kjetil Kristoffer Solberg
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Mon, 07 May 2007 08:47:02 -0700, Kjetil
<"kjetil[ANTI-SPAM]"@kjetil.infowrote:
>You are mistaken.
The MarshalByRefObject has a bad name. It's primary purpose is to
supress inlining by the JIT compiler so that the transparent proxy can
do it's job.
From the MSDN documentation for MarshalByRefObject:
Enables access to objects across application domain
boundaries in applications that support remoting.
There's nothing in there about inlining at all. In fact, on that page
(http://msdn2.microsoft.com/en-us/lib...refobject.aspx)
there is no reference to inlining at all.
You'd think that if the "primary purpose is to suppress inlining by the
JIT compiler", some mention of inlining would show up *somewhere* in the
documentation.
I don't find the claim that MarshalByRefObject has as its primary purpose
suppression of inlining is in any way credible.
>The JIT compiler checks to see if a class inherits from MarshalByRef
object and don't inline if it does.
It may well be that the compiler special-cases the class inheritance and
that inlining doesn't happen for particular classes, like
MarshalByRefObject. But that doesn't mean that's the purpose of
inheriting from MarshalByRefObject.
Pete