Today I wrote a QueryExpression which was throwing exception “The formatter threw an exception while trying to deserialize the message”.
The complete error message was:
“The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:query. The InnerException message was ‘Error in line 1 position 2016. Element ‘http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType’ contains data from a type that maps to the name ‘http://schemas.microsoft.com/xrm/2011/Contracts:EntityReference’. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name ‘EntityReference’ and namespace ‘http://schemas.microsoft.com/xrm/2011/Contracts’.’. Please see InnerException for more details.”
I was using ‘EntityReference’ in a condition, and error message gives hint that somehow there is an issue with ‘EntityReference’ format, and it is not being deserialized correctly. To use ‘EntityReference’ in condition we need to pass its ‘GUID’, and not complete ‘EntityReference’ object.
In the following QueryExpression, the condition will produce a similar exception which can be avoided by passing GUID instead of passing ‘EntityReference’ object as parameter.
QueryExpression query = new QueryExpression();
query.EntityName = “new_document”;
query.ColumnSet = new ColumnSet(“new_name”);
EntityCollection results =org.RetrieveMultiple(query);
Hi, good post.
I had a similar issue when using a plugin to manipulate the outpurtparameters on retrievemultiple message.
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Failed to assign a Licensing College: System.Runtime.Serialization.SerializationException: Element ‘http://schemas.microsoft.com/xrm/2011/Contracts:Entity’ contains data from a type that maps to the name ‘BDO.Infoway.Plugins.ProxyClasses:bdo_prescriberrole’. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name ‘xxx_prescriberrole’ and namespace ‘Xxx.Plugins.ProxyClasses’.
Do you have any clue?
Not sure but are you doing some serialization or dll MERGE?
Thanks Yawer. I’m doing any serialization in my code or dll merge. I write a plugin on retrieve multiple messages. The advance find will trigger it. When the retrieve returns 0 counts, the plugin will do another query and append the result, if any, to the outputparameter.
Sorry no idea. Please try d365 forums, will be quicker to get it resolved.
If merge what tool using for all MERGE?