locked
CRM 2015 - Service Context update error: The formatter threw an exception while trying to deserialize the message RRS feed

  • Question

  • Hi folks,

    I'm using CRM 2015 and SDK 7.1.1.

    Whent I use the CRMServiceContext for update and entity I receive this exception:

    {"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:request. The InnerException message was 'Error in line 1 position 13185. Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data from a type that maps to the name 'http://schemas.microsoft.com/xrm/7.1/Contracts:ConcurrencyBehavior'. 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 'ConcurrencyBehavior' and namespace 'http://schemas.microsoft.com/xrm/7.1/Contracts'.'.  Please see InnerException for more details."}

    I use this code:

    Uri organizationUri = new Uri("http://idefix/Standard/XRMServices/2011/Organization.svc");
    Uri homeRealmUri = null;
    System.ServiceModel.Description.ClientCredentials credentials = new System.ServiceModel.Description.ClientCredentials();
    OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
    orgProxy.EnableProxyTypes();
    IOrganizationService _service = (IOrganizationService)orgProxy;
    CRM.Model.CRMServiceContext ctx = new CRM.Model.CRMServiceContext(orgProxy);
    CRM.Model.Contact ct = ctx.ContactSet.Where(c => c.LastName == "Ultimo nome").FirstOrDefault();
    ct.JobTitle = "Modifca CTX";
    ctx.UpdateObject(ct);
    ctx.SaveChanges();

    I use the context for create a new contact all work fine. Only update return me the exception

    Thanks for any suggestion

    LSo


    LSo Lorenzo Soncini Trento TN - Italy

    Friday, October 23, 2015 11:38 AM

Answers

  • I have downloaded the version 7.0.1 of the SDK tools from NUGET:

    Install-Package Microsoft.CrmSdk.CoreTools -Version 7.0.1

    Using the 7.0.1 version of CrmSvcUtil.exe all work fine

    LSo


    LSo Lorenzo Soncini Trento TN - Italy

    Monday, October 26, 2015 3:41 PM

All replies

  • You can try below options.

    - Try same with late binding.

    - Try to update the proxy again

    - instead of updating the retrieved object. create new object. assign the Guid and update fields.

    CRM.Model.Contact ct = ctx.ContactSet.Where(c => c.LastName == "Ultimo nome").FirstOrDefault();

    Contact upCon=new Contact();
    upCon.Id=ct.Id 
    upCon.JobTitle = "Modifca CTX";
    ctx.UpdateObject(upCon);
    ctx.SaveChanges();


    Monday, October 26, 2015 3:31 PM
  • I have downloaded the version 7.0.1 of the SDK tools from NUGET:

    Install-Package Microsoft.CrmSdk.CoreTools -Version 7.0.1

    Using the 7.0.1 version of CrmSvcUtil.exe all work fine

    LSo


    LSo Lorenzo Soncini Trento TN - Italy

    Monday, October 26, 2015 3:41 PM