【问题标题】:Unable to connect via connection string to Dynamics CRM Online. Organization cannot be null or empty. Parameter name: Organization Name无法通过连接字符串连接到 Dynamics CRM Online。组织不能为空或为空。参数名称:组织名称
【发布时间】:2019-01-28 20:17:07
【问题描述】:

我正在尝试使用 Microsoft.CrmSdk.XrmTooling.CoreAssembly v 8.2.0.5 通过连接字符串连接到 CRM Online

按照MSDN 的指南,我的连接字符串如下所示:AuthType=Office365;Username=jsmith@contoso.onmicrosoft.com; Password=passcode;Url=https://contoso.crm.dynamics.com

但是,我收到 System.ArgumentNullException 类型的异常错误消息:组织不能为空或为空。 参数名称:组织名称

来源:Microsoft.Xrm.Tooling.Connector

public void GetClient()
{
    try
        {
            var client = new CrmServiceClient(GetConnectionString());
            Assert.IsTrue(client.IsReady);

        }
        catch (Exception ex)
        {
            throw;
        }

}
private string GetConnectionString()
{
    try
    {
        var connectionString = default(string);

        try
        {
            connectionString = "AuthType:Office365;Url=https://MyCRM.crm4.dynamics.com; UserName=ATMain@MyOrganization.com;Password=MySecretPasscode;"; 
        }
        catch (Exception ex)
        {
            throw;
        }
        return connectionString;
    }
    finally
    {

    }
}

【问题讨论】:

  • 您是否正在尝试连接到 CRM Online?也许您正在连接到某个本地实例并且只是使用了错误的身份验证类型?
  • 是的,我确实正在尝试连接到在线 CRM。
  • 粘贴 GetConnectionString 函数代码和 app.config 中的连接字符串(带有标签,但当然没有密码和登录名),我敢打赌你犯了一些简单的错误
  • 告诉你这是一个简单的错误。我发布了答案
  • 是的,完全错过了那个讨厌的结肠! :)

标签: c# dynamics-crm dynamics-365


【解决方案1】:

问题出在这里:

"AuthType:Office365; ..."

这应该是:

"AuthType=Office365; ..."

【讨论】:

    【解决方案2】:

    你必须像这样编写连接字符串:

     <add name="Server=CRM Online, 
    organization=contoso, user=someone"
    connectionString="Url=https://contoso.crm.dynamics.com;
    Username=someone@contoso.onmicrosoft.com; Password=password; authtype=Office365"/> -->
    

    sample to-do

    希望对您有所帮助!

    【讨论】:

    • 感谢 Javier,我使用相同的项目进行连接,但仍然出现相同的错误。
    【解决方案3】:

    您仍然需要将组织名称放在 url 的末尾,所以它应该是这样的:Url=https://contoso.crm.dynamics.com/contoso;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-06
      • 2018-02-11
      • 1970-01-01
      • 2020-01-29
      • 2018-07-28
      • 1970-01-01
      • 2020-10-24
      • 1970-01-01
      相关资源
      最近更新 更多