简体   繁体   中英

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

I'm trying to connect to CRM 365 on-premise through C# but I got an error :-

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.

My connection code is :-

        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);

I got the above error when I start using "serviceProxy" to create record or retrieve record. Ex : serviceProxy.Create(Entity);

any suggestion please.

My preferred way to connect a console app to D365 is using Microsoft.Xrm.Tooling.Connector.CrmServiceClient

This article outlines the various connection string formats.

It looks like your org is on-prem, so you can either use integrated security:

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

Or specify user credentials:

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

Please note the org name appended to the URL in the connection string (in this case "Test")

Also, the above code requires:

using Microsoft.Xrm.Tooling.Connector;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM