I’m trying to wrap my head around this to make the correct design decisions.
Say I create a new appdomain B, create an instance of an object O inside it and then pass a reference to that object back to appdomain A, so that A can make calls like:
O.SomeMethod(parameter)
The code in SomeMethod will run in appdomain B, which is what I expect. I’m wondering what happens to the parameter and return value. Are they serialized using binaryformatter and passed by value, or is a reference to that data just passed between appdomains?
I’m hoping that it’s the latter, which means you can have O.SomeMethod() return large amounts of data with no serialization penalty.
Thanks!
Arguments that are passed to the function need to pass the appdomain boundary before the method is called. The returned value also needs to pass the boundary (in the other direction).
Anytime an object needs to pass the boundary it’s:
MarshalByRefObject; orMBRO.To answer your question, yes, arguments are serialized and then deserialized, unless they inherit from
MBRO.