If a class is not marked Serializable you can try serialization using SerializationSurrogate.
If a class is not marked Serializable, you can try serialization using SerializationSurrogate.
Thanks Ram. I will look into it – Ashwani K Apr 2 '10 at 4:50 This still does not solve my problem, but it helped me in learning run time serialization. Thanks.
– Ashwani K Apr 2 '10 at 7:06.
You cannot modify the metadata of an existing class at runtime.
– Ashwani K Mar 17 '10 at 10:38 @Ashwani, you could create another class which encapsulates the real class and which is marked with Serializable and then work with this class. – Darin Dimitrov Mar 17 '10 at 10:40 You're not talking about the difference between debug mode and release mode are you? – Andrew Bienert Mar 17 '10 at 10:40 @Andrew Bienert: No, like we can the see the data of a data table in data set visualizer, I created my own visualizer for list of class object to show list data in data table.
– Ashwani K Mar 17 '10 at 10:44.
The fact that a class is missing Serializable can be explained two ways. It might be an error of omission, the more common case. Or the class can simply not support serialization.
Which is not unusual, classes often depend on state that cannot be faithfully reproduced at deserialization time because it depends on global program state. Any of the Windows Forms controls would be a good example, they can't be deserialized without having a native Windows window that is in the required state, a state that often requires other windows to be created as well (like the container window) and many messages. Well, this isn't going to help you implement your visualizer.
You can't reliably implement it with serialization. Using reflection however gives you access to the same property and field values. And reflection is always supported.
You could look at your question differently, using Serializable allows you to use the dotnet libraries to serialize into json, xml etc. You can still serialize by writing your own methods to do so as fundamentally just about any data structure can be represented in xml or json format. Adding Serializable to classes is one of the best practice tips in Bill Wagner's brilliant book Effective C#: 50 specific ways to improve your C#. You can serialize a class without it being Serializable as @Darin (+1) pointed out you can't retrospectively redecorate a class.
If I were you I'd put in Serializable as working around this is not worth the effort.
Thanks. Just out of curiosity, does putting Serializable attribute for a class has any performance hit? I mean should we include serializable attribute for any class which we create?
– Ashwani K Mar 17 '10 at 10:51 @Ashwani Bill Wagner recommends the practice in Effective C# - I don't have the book to hand, but when I read the section on why it should be the default the argument was compelling. This answer on SO confirms that there is no performance hit - stackoverflow. Com/questions/1402903/… – amelvin Mar 17 '10 at 12:18 Thanks Amelvin.
– Ashwani K Mar 22 '10 at 4:15 No problem at all. – amelvin Mar 22 '10 at 10:16.
Any class with public get/set properties is XmlSerializable. Can you use XML serializers instead?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.