MarshalByRefObject on member of Serializable class RRS feed

  • Question

  • I have a class with a lot of value members and a few very big reference members, like this:

    public class Data
      string Name {get;set;}
      int AnInt {get;set;}
      int AnotherInt {get;set;}
      List<Object> HugeList;  
    I want to marshal instances of this class by value, except that I only want to pass the HugeList member when specifically requested by a client.

    If I mark HugeList [NonSerialized] and then add a GetHugeList() method it won't work because the Get method will look at the local copy of the class instance, where HugeList will be null because it's not Serialized.

    Is there any trick to do all of the following:
    1. Keep the large members in the class
    2. Marshal instances of the class by value, except for the large members
    3. Allow a remote client to explicitly request a serialized copy of the large members
    Thursday, January 28, 2010 7:28 PM


  • Hi,

    I don't think this is achievable within one class object, you'd better to have the value member in one struct and the Hugelist in another class object.

    In this case you can make copy with the struct and use proxy on your class on remote client.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bin-ze Zhao Thursday, February 4, 2010 3:40 AM
    Tuesday, February 2, 2010 7:29 AM