Click here to Skip to main content
15,881,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm working on a ASN1 decoding project. I've faced a problem that I could't figure out! The problem is ASN1C program is creating classes for me to use them for decoding process. But after decoding process I need to be able to serialize that class. But the problem is those classes (which are about 6000 classes)are being created without serializable attribute. So I need to add them attributes "serializable".
Is there any way to do this dynamically?

I'll appreciate any help.

Thanks in advance
Posted
Comments
E.F. Nijboer 4-Oct-10 7:21am    
I have never tried this, but it might be as simple as wrapping such an object in a class that has been declared with the serializable attribute.
kubi081 4-Oct-10 9:11am    
The classes are being created by an external program without serializable attribute. The problem is adding this attribute to those classes at runtime?
ely_bob 4-Oct-10 14:37pm    
Yes and no maybe...


I believe it should be possible to dynamically create an "serializedto" object, and cast it to a known instance of an object, it would be VERY ugly if it was attempted this way, in that you would never really be able to properly debug (if your using the datacontract attribute).. how you would actually do this, would be a "reflection work-around" where you build an object type(structure)(dynamically) at runtime... Now I don't know that this can be done, but It seems like all the stuff is there if someone was brave enough to try to do it...
kubi081 5-Oct-10 2:33am    
Yes, I prefer to use DataContract attribute, I know it is not easy but there must be a way to do this at runtime! Or can I create a tool that adds attributes to any class?
PumbaPumba 5-Oct-10 15:08pm    
@kubi081 if you want DataContract. I would say go for creating your own utility to add the attributes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900