Does [Serializable] work for inherited classes?
I haven't worked much with remoting so excuse this rather rudimentary question, If I derive a class from an abstract class marked as [Serializable] (for passing the data across an appdomain), does the other side get the actual overriden implementation? ie does polymorphism work over remoting/Serializable?
I need to create a clone on the other side rather than operating on the original so MarshalByRef is not an开发者_开发知识库 option...
The easiest way to see that [Serializable] is not inherited is press F12 and see "Inherited = false" in AttributeUsage. The harder option is to RTFM at http://msdn.microsoft.com/en-us/library/bcfsa90a.aspx .
Essentially you need to mark all you classes as serializable and they will be deserialized properly.
Yes when you deserialize a type, the same type is reconstituted in the remote domain.
You can control the deserialized type by using the IObjectReference pattern:
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iobjectreference.aspx
精彩评论