Type...is not marked as Serializable()... grr...

Type...is not marked as Serializable()... grr...

Old forum URL: forums.lhotka.net/forums/t/2086.aspx


skagen00 posted on Friday, January 05, 2007

A .Net class that I'd like to be Serializable() isn't. Namely, SettingsPropertyCollection and SettingsPropertyValueCollection.

When creating a Csla-enabled Profile Provider for ASP.Net, these two (which contain non-serializable members of SettingsProperty and SettingsPropertyValue, respectively) uncovered the fact that they weren't serializable.

I'm sure some of you may have encountered this sort of situation with other classes, and was wondering - what did ya do?

Perhaps my only alternative is to create Serializable() transport objects for them - but that's a pain. Can't I just edit the .Net 2.0 Framework and put that Serializable() tag in there?? :)

Any suggestions appreciated.

ajj3085 replied on Friday, January 05, 2007

Unfortunately I think the only way to handle this is create those transport objects and give them enough data to recreate the non-serializable objects on either end of the data portal.

skagen00 replied on Friday, January 05, 2007

Thanks Andy, kinda what I figured but doesn't hurt to ask. :)

xal replied on Sunday, January 07, 2007

You could try calling redmond and asking for the sources....
Or you could implement those classes yourself and handle that.


A simple way to overcome this would be to handle serialization events and read the values of the properties with reflection, add them to a hashtable and then reading them when the object is deserialized.
You could build a custom method that does this and that would work for any object in the future... Although it's not as simple as it sounds, because the objects themselves could have properties of types that are not serializable. You'll have to use recursion in that case.

Andrés

Copyright (c) Marimer LLC