简体   繁体   中英

serialize a non-serializable object of type Type?

I have an object of type Type

Type typ = CreateDynamicType();

and the creating object of that Type

object instance = Activator.CreateInstance(typ);

This instance is creating fine .Still no problem. Now i have two methods CreateRawXML(),createSOAPXml(). Both serialize the object and return serializable string.I need a rawxml and a SOAPXML.In first case Raw XML is creating fine but when i tried to create SOAPXML it's getting error(Can not serialize object).i check the isserializable property of that object its False.As its metadata and a read only property i can't change it ..

Either i have to create a serialize object from that non-serializable object Or i need to create SOAPXML from Raw XML Or something else ...Please suggest ...

I am creating that Type class from CreateDynamicType() method on the fly using reflection . I am doing it all for a WCF request Please suggest

You may not need to serialize Type - consider if serializing full name of the type (possibly with full name of assembly it coming from to make loading of the type easier) is enough for your case.

Definitely if you try to create an object of this type in some remote process just full type name is enough (assuming the other process have access to assembly implementing the type).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM