【问题标题】:CRM 2015 + Metadata contains a reference that cannot be resolvedCRM 2015 + 元数据包含无法解析的引用
【发布时间】:2016-08-08 11:53:49
【问题描述】:

我创建了一个控制台应用程序,它连接到 CRM 并更新 XYZ 实体中的字段。

连接到 CRM 的代码是 -

ClientCredentials credential = new ClientCredentials();
credential.UserName.UserName =user;
credential.UserName.Password = password;

OrganizationServiceProxy proxy = new OrganizationServiceProxy(new Uri(crmEnvironments.ElementAt(currentEnvironment).URL), null, credential, null);

它最初可以很好地连接到 CRM,但一段时间后它会抛出下面提到的错误 -

“元数据包含无法解析的引用”。

内部异常:“无法连接到远程服务器”

在对google做了一些研究之后,我做了以下事情

在 Connect CRM 中插入以下代码行 -

ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain,SslPolicyErrors sslPolicyErrors) { return true; };

在 Appconfig 文件中插入以下内容 -

<system.net>
 <defaultProxy useDefaultCredentials="true">
 </defaultProxy>
 </system.net>

但是错误仍然存​​在,处理一些记录后连接失败并抛出上述错误。

请帮忙。

【问题讨论】:

    标签: dynamics-crm dynamics-crm-2015


    【解决方案1】:

    你有什么样的部署?是使用 Active Directory 还是 IFD 的 OnPremise?

    之所以这么说,是因为您只需要 ServerCertificateValidationCallback 如果您通过 SSL 托管 CRM 并使用上述方法实际绕过的自签名证书。

    如果它处理一些记录然后停止,那么我敢打赌 ServerCertificateValidationCallback 与此无关。例如,CRM 可能会因为您超过超时而断开连接。

    您可以在 CRM 的 web.config 中增加 OrganisationService 超时。

    查看更多详情here

    如果可能的话,另一个更好的选择是将您的个人调用包装到一个 ExecuteMultipleRequest 中,这样您就不会对服务进行 N 次调用,而只是一次大调用(这将节省网络带宽和连接问题)。

    【讨论】:

    • 感谢您的回复。我正在研究 CRM 2015 Online。如果你不介意,你能建议我一个使用 ExecuteMultipleRequest 的例子吗?
    【解决方案2】:

    连接控制台应用的另一种方法是 CrmServiceClient,它位于 Microsoft.Xrm.Tooling.Connector 库中。

    使用 NuGet,您可以获得Microsoft.CrmSdk.XrmTooling.CoreAssembly 包,然后您就可以参加比赛了。

    这里有几个其他有用的链接:

    Build Windows client applications using the XRM tools

    Sample: Quick start for XRM Tooling API

    以下是各种连接字符串示例:

    CRM 2016 和 Dynamics 365 在线:

    <add name="dev26" connectionString="Url=https://dev26.crm.dynamics.com; Username=user@dev26.onmicrosoft.com; Password=Pass; AuthType=Office365" />
    

    具有集成安全性的本地部署:

    <add name="prod" connectionString="Url=http://myserver/AdventureWorksCycle;"/>
    

    使用凭据进行本地部署:

    <add name="prod" connectionString="Url=http://myserver/AdventureWorksCycle; Domain=mydomain; Username=administrator; Password=password; AuthType=AD;"/>
    

    CRM 2016 之前的本地 IFD:

    <add name="prod" connectionString="Url=https://contoso.litware.com; Username=someone@litware.com; Password=password; AuthType=IFD;"/>
    

    适用于 CRM 2016 及更高版本 (v8.0+) 的本地 IFD

    <add name="prod" connectionString="ServiceUri=https://contoso.litware.com/contoso; Domain=contoso; Username=contoso\administrator; Password=password; AuthType=IFD; LoginPrompt=Never;" />
    

    【讨论】:

      【解决方案3】:

      我知道这个问题被问到已经有几年了;但我今天在尝试连接到 CRM 365 Online 时遇到了这个问题。

      我在尝试连接时不断收到空对象错误 - 结果发现根本原因是我没有在 app.config 文件中配置代理凭据。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-24
        相关资源
        最近更新 更多