Is MarshalByRefObject special?
The magic seems to be in a special TransparentProxy
class - the .NET Runtime handles it in a special way.
- If you want to use it, see an article about RealProxy
- If you want to read more about the "magic", see an article on TransparentProxy implementation.
- For a basic overview, try the MSDN article "Remoting: A Technical Overview".
I think that MarshalByRefObject
may contain some additional internal information which can be helpful for this mechanism, but I haven't looked much into that.
I believe MarshalByRefObject isn't all that special. I believe that its whole reason for existence lies with its lifetime management and how it's garbage-collected on the server. There are some good comments on what this is about in the LifetimeServices class documentation.
AFAIK, the real magic of remoting is done by the remoting infrastructure yourself when you set up the hosts. MarshalByRefObject isn't doing any of the real work of marshalling stuff across AppDomains.