Recently I found that a method with custom class parameter doesn’t have one of the properties updated after return, even if it is certainly updated inside the method.
Object passing. All objects created remotely are returned by reference and have to derive from MarshalByRefObject. Objects passed as parameters to a remote method call can be forwarded by value or by reference. The default behavior is pass by value provided the object in question is marked by the custom attribute [Serializable]. Additionally, the object could implement the ISerializable interface, which provides flexibility in how the object should be serialized and deserialized. Objects that are not marshal by reference or marshal by value are not remotable.
Because parameter ForwardMe does not inherit from MarshalByRefObject, it is passed by value to the server.
And finally, article Copying, Cloning, and Marshalling in .NET clarified it:
By default, all objects in .NET (both value- and reference-types) are marshalled by value when sent across the “wire” to a remote AppDomain.To override this default MBV behavior, one can simply derive one’s class from
So the Rules for passing parameters in .Net Remoting are the following:
2. If parameter is serializable, it is passed by value. Changes inside remote methods do not return to the client.
3. If parameter derive from MarshalByRefObject , it is passed by reference.
4. I am not sure, what happens If you specify modifier ref for serializable parameter. I hope that it is also passed by reference, but not sure.
The following links discuss how parameters are treated in WCF: