How to connect to Crm Dynamics On Premis 2016 with Consol App

private static void ConnectToCRM()
string OrganizationURL = ConfigurationManager.AppSettings["OrganizationURL"];
OrganizationURL += "/XRMServices/2011/Organization.svc";
_orgServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(OrganizationURL));
ClientCredentials Credentials = new ClientCredentials();
Credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
_service = new OrganizationServiceProxy(_orgServiceManagement, Credentials);
//LogHelper.Info("\r\nConnected to {0}\r\n ", OrganizationURL);
WhoAmIRequest req = new WhoAmIRequest();
WhoAmIResponse resp = (WhoAmIResponse)_service.Execute(req);
// LogHelper.Info("User ID: " + resp.UserId);
//Guid currentUserId = resp.UserId;
catch (Exception ex)
Console.WriteLine("An error occured trying to connect to the MS CRM Server.\nPlease verify your login data.");
app.config file

<?xml version="1.0" encoding="utf-8" ?>


<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<add key="OrganizationURL" value="http://crmUrl/Organization/" />


Posts les plus consultés de ce blog

CRM dynamics V9 wait Async web API to contiue code

Decode/render HTML from a field in crm dynamics

Make CRM Faster