2012-12-05 37 views
0

我有一个CRM函数,它返回实体中所有属性的属性类型。我的问题是尽管这个方法在过去一直工作,但现在抛出这个错误,无论我传入它的实体如何。尝试反序列化参数时出现CRM错误

尝试反序列化参数http://schemas.microsoft.com/xrm/2011/Contracts/Services:ExecuteResult

这里是我的代码,我传递的“账户”实体时出错。

public string GetFieldType(IOrganizationService svc, string entity, string fieldName) 
     { 
      RetrieveEntityRequest request = new RetrieveEntityRequest() 
      { 
       EntityFilters = EntityFilters.Attributes, 
       LogicalName = entity 
      }; 

      RetrieveEntityResponse response = (RetrieveEntityResponse)svc.Execute(request); 
      string type = ""; 
      foreach (AttributeMetadata attribute in response.EntityMetadata.Attributes) 
      { 
       if (attribute.LogicalName == fieldName) 
       { type = attribute.AttributeType.ToString(); } 
      } 

      return type; 
     } 
+1

您使用的是早期绑定的实体吗? –

回答

0

如果代码在以前工作,现在不是现在,可能性是它不是代码问题。很可能您的svc.Execute失败。你有没有改变你的IOrganizationService正在创建?您是否以具有查询CRM实例权限的用户身份运行?如果所有这些东西都检出,然后尝试通过diagnostic tool打开服务器端跟踪。

相关问题