Saturday 22 June 2019

Connecting to D365 Using Xrm.Tooling Connector via Console App

One of the easiest way to connect to a Dynamics 365 CE instance, is to leverage the value of app.config.
Using the below configuration & just placing your organisation related values, you should be able to connect to D365 CE instance within a matter of minutes.

Ensure that the reference to the Microsoft Tooling Connector is added via nuget.
You can add this via nuget manager by searching for "Microsoft.CrmSdk.XrmTooling.CoreAssembly"  and pick up the one that is authored by either Microsoft or crmsdk.


Paste Below in app.config:

<connectionStrings>
    <add name="MyCDSServer" connectionString="AuthType=Office365;Url=http://some:8080/Test;UserName=someone@some.onmicrosoft.com;
  Password=passcode" />
</connectionStrings>


Below code from Main:

static void Main(string[] args)
        {
            CrmServiceClient serviceClient = new CrmServiceClient(ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString);
            IOrganizationService service = serviceClient.OrganizationServiceProxy;
        }


No comments:

Post a Comment