Search code examples
.netwcfreflectiondatacontractreflection.emit

TypeBuilder with DataContract and DataMembers


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.


Solution

  • 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.