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;
        }
4

1 回答 1

0

If the code was working before, and it's not now, odds are that it is not a problem with your code. Most likely your svc.Execute is failing. Have you changed how your IOrganizationService is being created? Are you running as a user with rights to query the CRM instance? If all of these things check out, then try turning on server side tracing through the diagnostic tool.

于 2012-12-05T18:59:23.413 回答