EntityCollection serialization over WCF

Posts   
 
    
Posts: 34
Joined: 05-Mar-2008
# Posted on: 02-Aug-2011 10:06:28   

Hi,

I have got problem with EntityCollection xml serialization over WCF(with NetDataContractSerializer). This code below:

Entity1 e1 = new Entity1()
Entity2 e2 = new Entity2()

WCFService.SaveEntityCollection(new EntityCollection<EntityBase2>(){e1, e2});

Generates this exception:

ORMGEneralOperationException: There's no entity factory set nor defined in the XML. Can't deserialize entity collection XML

Method: Xml2EntityCollection Class: EntityCollectionBase2 Stack Trace: at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase21.Xml2EntityCollection(XmlReader reader, Dictionary2 processedObjectIDs, List1 nodeEntityReferences) in G:\MyProject\DataAccess\SD.LLBLGen.Pro.ORMSupportClasses.NET20\AdapterSpecific\EntityCollectionBase2.cs:line 983 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase21.ReadXml(XmlReader reader, XmlFormatAspect format) in G:\MyProject \DataAccess\SD.LLBLGen.Pro.ORMSupportClasses.NET20\AdapterSpecific\EntityCollectionBase2.cs:line 713 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2`1.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader) in G:\MyProject DataAccess\SD.LLBLGen.Pro.ORMSupportClasses.NET20\AdapterSpecific\EntityCollectionBase2.cs:line 1870 at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadIXmlSerializable(XmlSerializableReader xmlSerializableReader, XmlReaderDelegator xmlReader, XmlDataContract xmlDataContract, Boolean isMemberType) at System.Runtime.Serialization.XmlDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context) at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader) at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns) at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns) at System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) at System.Runtime.Serialization.NetDataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName) at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest) at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part, Boolean isRequest) at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest) at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest) at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest) at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)

Regards

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 02-Aug-2011 10:40:18   

IMHO, that's expected.

As you pack 2 entities of different types in one collection of type EntityBase2, and you send the collection over the wire, that's when the deserialization routine finds no information about the type of the collection and hence the enclosed entities, to be able to deserialize them back.