Mixing MarshalByRefObject and Serializable

后端 未结 2 1831
梦如初夏
梦如初夏 2020-12-31 22:52

Various sources explain that

When an object derives form MarshalByRefObject, an object reference will be passed from one application domain to anoth

2条回答
  •  耶瑟儿~
    2020-12-31 23:40

    It is my understanding that only the top-level object that is passed may be MBR. In your scenario, since List is not MBR, when it is passed over the boundary, you will receive serialized copies.

    This section in the MSDN documentation explains this behavior:

    MarshalByRefObject is the base class for objects that communicate across application domain boundaries by exchanging messages using a proxy. Objects that do not inherit from MarshalByRefObject are implicitly marshal by value. When a remote application references a marshal by value object, a copy of the object is passed across application domain boundaries.

    So, since the class (List) that is passed is not MBR, it will be serialized, along with its contents.

    Also, while not directly applicable to the question, the following behavior is very important to note:

    ... the members of the object are not usable outside the application domain where they were created.

提交回复
热议问题