CRM 2015 SDK : The deserializer has no knowledge of any type that maps to this name

10,301

Solution 1

Not 100% what the issue is but I would suggest trying the following to see if it helps.

  1. Regenerate your proxy, it might be a case that your proxy is out of date which is why the deserializer has no knowledge of any type that maps to this name.

  2. Try using late bound just to see if that works, help to narrow things down if there is a problem in the early bound code. For example:

Entity account = new Entity("account"); account.Id = new Guid(""); account["new_link"] = "your value"; service.Update(account);

  1. Break point the code and see what values are being updated on the account objects, e.g. make sure another attribute doesn't have an odd value.

Solution 2

Also the problem might be unknown types. It's important to enable proxy types on OrganizationServiceProxy. It solved my issue with similar error

using (OrganizationServiceProxy proxy = new OrganizationServiceProxy(organizationUri, null, credentials, null))
{
   proxy.EnableProxyTypes();
}

Solution 3

I will share my solution to this problem, when using own created WCF services, which are using generated models from CRM.
When referencing the WCF service in other project using VS 2017, there are some options in the Add Service Reference window: press "Advanced..." and uncheck Reuse types in referenced assemblies

enter image description here

Hope it helps someone.

Share:
10,301

Related videos on Youtube

Pierre-Alexandre Moller
Author by

Pierre-Alexandre Moller

Computer science is no more about computers than astronomy is about telescopes.

Updated on October 09, 2022

Comments

  • Pierre-Alexandre Moller
    Pierre-Alexandre Moller over 1 year

    I am currently working with CRM 2015 SDK. I am simply trying to update a value in C# with this SDK. But for some reasons that I try to figure out, there is a trouble when I save my context.

    There is the code :

    foreach (KeyValuePair<string, Account> account in dicAccount)
    {
        //Calcul of url/login/date/key/customer values
        string generatedUrl = Utilities.GenerateURL(url, login, date, key, customer);
      account.Value.new_Link = generatedUrl;
      if (!context.IsAttached(account.Value))
       {
           context.Attach(account.Value);
       }
       context.UpdateObject(account.Value);
    
     }
     SaveChangesResultCollection results = context.SaveChanges(SaveChangesOptions.ContinueOnError);
      if (results != null)
      {
           foreach (SaveChangesResult result in results)
               {
                  Type type = result.Request.GetType();
                  bool hasError = result.Error != null;
                  Entity entity = (Entity)result.Request.Parameters["Target"];
                 if (type == typeof(UpdateRequest))
                    {
                        if (hasError)
                           {
                              if (entity != null)
                                 {
                                      log.Error(result.Error.Message); 
                                 }
                            }
                       }
    

    On my Dynamics entities, I have this :

    [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("new_link")]
    
    public string new_Link
    {
        get
        {
            return this.GetAttributeValue<string>("new_link");
        }
        set
        {
            this.OnPropertyChanging("new_link");
            this.SetAttributeValue("new_link", value);
            this.OnPropertyChanged("new_link");
        }
    }
    

    Right now, I got this error printed by the LogError :

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

    After few searchs, I found 2 possible causes :

    1. Enable Proxy type : the fact is I have the code to do that. So this couldn't help me.

      _serviceProxy.EnableProxyTypes();

    2. Version of SDK : I saw some answers about the fact that the SDK version 7.0 can cause this problem. The fact is that I am using the version 7.1 and I also try with the latest 7.1.1. I use this DLL's : Microsoft.Xrm.Client, Microsoft.Xrm.Sdk, Microsoft.Crm.Sdk.Proxy

    3. Type of this element : I also try with a basic string as datatype. There is still problem of serealization.

    None of these ideas solve my problem and right now, I do'nt really know where I am suppose to look into to solve fix this problem.

  • David Klempfner
    David Klempfner about 8 years
    That fixed it for me! Thanks.