Serailizing CodeDom generated class using WCF
-
Hi, I am trying to send an object of a dynamically generated class to the client using WCF Service with TCP/IP as protocol. I am generating this class dynamically using CodeDom. First problem: When generating the class dynamically i am not able to mark the class as [DataContract]. It says that DataContract is not found in namespace System.Runtime.Serializable. The same is the case with adding [DataMember] attribute on properties. I have tried adding other attributes like [System.Seriazable()] and that works fine. Second problem: This dynamic type inherits from a base class named "DOPositionBase". While sending i assign the dynamic type "Position" to an object of its parent type "DOPositionBase". But upon trying to send it to the client an error occurs at the server saying "The type "Position" was not expected. Try adding known types that were not statically defined." I cannot define the KnownTypes as the type at design time is unknown. How to proceed then. Please let me know if anyone has ideas about these 2 problems.
Pankaj Chamria, Software Programmer.