0

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

按照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
    {

    }
}
4

3 回答 3

4

问题在这里:

"AuthType:Office365; ..."

这应该是:

"AuthType=Office365; ..."
于 2017-07-11T08:16:30.293 回答
0

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

 <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"/> -->

样品待办事项

希望这有帮助!

于 2017-07-11T07:41:36.137 回答
-1

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

于 2019-01-28T12:17:07.317 回答