1
votes

I'm generating a dynamic type on the fly with a DataContract attribute and DataMembers. I've verified the type is getting generated correctly with DataContract and DataMember attributes using reflection on the generated type.

I then generate a ServiceContract type on the fly that includes operation with said types.

However, when I add a ServiceReference from the client, my DataContract types get generated with the client with no properties/DataMembers.

Any idea what's going wrong here?

Thanks.

1
Any chance you could share how you were able to set DataContract and DataMember attributes on the fly?sanpaco
I used a standard TypeBuilder with simple properties. What specifically did you want to know?Jeff
How do you add the DataContractAttribute to the TypeBuilder? And how do you add DataMemberAttribute to the PropertyBuilder? I'm trying to serialize my custom object in WCF but that requires DataContract and DataMember in the class definition. It sounds like I'm pretty much trying to do what you have already done, any chance you could show me some examples.sanpaco

1 Answers

0
votes

Answer Here:

http://www.netframeworkdev.com/windows-communication-foundation/datacontractserializer-not-serializingdeserializing-type-built-with-typebuilder-65973.shtml

My TypeBuilder properties' methods were marked with MethodAttributes.Virtual.

Another great well documented feature of the DataContractSerializer.