Silverlight WCF serialization DataContract(IsReference=true) problem
- by Ciaran
Hi,
I'm have a Silverlight 3 UI that access WCF services which in turn access respositories that use NHibernate. To overcome some NHibernate lazy loading issues with WCF I'm using my own DataContract surrogate as described here: http://timvasil.com/blog14/post/2008/02/WCF-serialization-with-NHibernate.aspx. In here I'm setting preserveObjectReferences = true
My model contains cycles (i.e. Customer with IList[Order])
When I retrieve an object from my service it works fine, however when I try and send that same object back to the wcf service I get the error:
System.ServiceModel.CommunicationException
was unhandled by user code
Message=There was an error while
trying to serialize parameter
http://tempuri.org/:searchCriteria.
The InnerException message was 'Object
graph ...' contains cycles and cannot
be serialized if references are not
tracked. Consider using the
DataContractAttribute with the
IsReference property set to true.'
So cyclical references are now a problem in Silverlight, so I try change my DataContract to be [DataContract(IsReference=true)] but now when I try to retrieve an object from my service I get the following exception:
System.ExecutionEngineException was unhandled Message=Exception of
type 'System.ExecutionEngineException'
was thrown. InnerException:
Any ideas?