首页 文章

尝试反序列化参数时出现CRM错误

提问于
浏览
0

我有一个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打开服务器端跟踪 .

相关问题