From: hammett <ha...@uo...> - 2004-10-27 15:18:00
|
Hiya, (I'm cc rodrigo wondering if he knows a better solution) Our problems with serialization regard mostly people that serialize an object model with aspects involved and need to retrive them later as they were. Seems easy but its a bit tricky: - The types are transient types in an transient assembly. The CLR is not able to serialize them - The proxy must serialize the state of the base class unaware of how the base class has chosen the serialization method (flag or ISerializable interface) My suggestion is very intrusive, but it works: 1. Types that want to be serialized and that you know up front will be proxied must use the ISerializable interface. 2. The dynamic proxy generated will implement the GetObjectData saving its information and calling the base GetObjectData and setting a custom IObjectReference, which is not transient. 3. The dynamic proxy will expose a public constructor to deserialization just to delegate to the base class deserialization constructor 4. The custom IObjectReference should recreate the proxy and invoke the deserialization constructor Caveats: to guarantee the correct behavior we need to force classes marked as serializable to implement both methods, which translates to: if you want to proxy a class marked as serializable, an error will be raised unless you implement the constructor and the virtual GetObjectData. This is terrible. Anyone has a better solution? Or we can put off this for now. -- Cheers, hammett http://www.digitalcraftsmen.com.br/~hammett |