无法连接到内部部署的 MS CRM 365?

Not able to connect to MS CRM 365 on-premise?

我正在尝试通过 C# 连接到内部部署的 CRM 365,但出现错误:-

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

我的连接码是:-

        ClientCredentials credentials = new ClientCredentials();
        credentials.UserName.UserName = ConfigurationManager.AppSettings["CRMUser"]; //I Tried with & without domain name Ex: domain\crmadmin and crmadmin
        credentials.UserName.Password = ConfigurationManager.AppSettings["CRMPassword"]; //Ex : 123456

        string CRMURL = ConfigurationManager.AppSettings["CRMURL"].ToString(); // http://domain/XRMServices/2011/Organization.svc

        OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(new Uri(CRMURL), null, credentials, null);

当我开始使用 "serviceProxy" 创建记录或检索记录时出现上述错误。 例如:serviceProxy.Create(实体);

有什么建议吗

我将控制台应用程序连接到 D365 的首选方法是使用 Microsoft.Xrm.Tooling.Connector.CrmServiceClient

This article 概述了各种连接字符串格式。

看起来您的组织是本地的,因此您可以使用集成安全性:

var connectionString = "AuthType=AD;Url=http://contoso:8080/Test;" 
var svc = new CrmServiceClient(connectionString);

或指定用户凭据:

var connectionString = "AuthType=AD;Url=http://contoso:8080/Test; Domain=CONTOSO; Username=jsmith; Password=passcode" 
var svc = new CrmServiceClient(connectionString);

请注意连接字符串中附加到 URL 的组织名称(在本例中为 "Test")

另外,上面的代码需要:

using Microsoft.Xrm.Tooling.Connector;