Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the major use of MarshalByRefObject?

Tags:

c#

.net

What's the purpose for MarshalByRefObject?

like image 920
user496949 Avatar asked Nov 28 '10 07:11

user496949


4 Answers

Remoting; it means that between AppDomains or machines, rather than serialize and transfer the object, the object stays at one end and a proxy is created at the other. All method calls to the proxy are intercepted and the call is transmitted as RPC wiki, msdn, causing the method to execute on the other machine (typically serialising the arguments and return value).

Note: this can lead to unexpectedly "chatty" interfaces. The object/proxy/RPC approach is now less preferable to approaches with an explicit service boundary; Microsoft now recommends WCF wiki, msdn instead of remoting.

like image 182
Marc Gravell Avatar answered Oct 19 '22 18:10

Marc Gravell


Another important use of MarshalByRefObject is for implementing AOP via remoting sink-chains.

If you have an object that derives from ContextBoundObject (which itself derives from MarshalByRefObject) you can instantiate it in a separate Context within the same AppDomain and have communications between objects automatically go through the Remoting proxy system - allowing you to plug custom sinks into the Remoting sink-chain.

This ultimately allows you to 'decorate' method calls to your objects and implement cross-cutting services, such as logging and security etc.

like image 24
Dean Chalk Avatar answered Oct 19 '22 16:10

Dean Chalk


it basic use is for support access of objects between two appdomains and these appdomains can be on the same computer or in the different computers via remoting.

See Here

like image 9
TalentTuner Avatar answered Oct 19 '22 18:10

TalentTuner


Any object outside the application domain of the caller application should be considered as Remote Object. A Remote Object that should be derived from MarshalByRefObject Class. Any object can be changed into a Remote Object by deriving it from MarshalByRefObject. Objects without inheriting from MarshalByRefObject are called Non-remotable Objects.

like image 5
Arvind Singh Avatar answered Oct 19 '22 18:10

Arvind Singh