Tip #556: Rumors about Microsoft.Xrm.Client death are exaggerated

Update 18-Nov-2016: Bugs reported have been fixed and there are no compelling reasons (beyond the support of the existing codebase) to continue use of Microsoft.Xrm.Client.

One thing you’d notice about Dynamics CRM 2016 SDK is that some of the assemblies has gone MIA. For example, Microsoft.Xrm.Client, a home to some useful developers extensions, including a mighty CrmConnection class, is nowhere to be found. These extensions were taken over by Xrm Tooling family, the one we mentioned before.

CrmServiceClient, in particular, looks like a solid replacement for CrmConnection but, as with any new libraries, there are few gotchas.

This is the only connection string that worked for us so far in non-interactive mode:

CrmServiceClient conn = new CrmServiceClient(
   "ServiceUri=https://orgname.contoso.com/orgname;" + 
   "AuthType=IFD;Domain=anything;" + 
   "UserName=george@contoso.com;Password=pass@word1;" + 

Note the following:

  • Url must be in the form of https://orgname.contoso.com/orgname. For on-premises and IFD deployments the connector expects orgname to be at the end and looks like it does not make any attempt to deduce orgname from the server url.
  • Domain name must be specified but it’s not passed via claims, so it can be anything. Really any non-empty string o__O
  • Username must be UPN. If it’s not, then, since domain name is not passed it, ADFS 3.0 throws a fit (ADFS 2.0 assumes the domain)

The following syntax works as well:

CrmServiceClient conn = new CrmServiceClient(
   new System.Net.NetworkCredential(
       "george@contoso.com", "pass@word1"),
   "orgname.contoso.com", "443", 
   "orgname", useSsl: true);

Same restrictions apply except that there is no need to specify the dummy domain name.

Whilst we manage to get CrmServiceClient working for non-interactive IFD connections, we’re heard from reliable sources that it does not work currently in Azure Web Apps / App Service Web Apps while attempting to connect to CRM Online.

The workaround? You can still use the bits from CRM 2015 SDK and its very reliable CrmConnection class – just make sure to load the other Nuget packages for CRM 2016 first and then add Microsoft.Xrm.Client.

5 thoughts on “Tip #556: Rumors about Microsoft.Xrm.Client death are exaggerated

  1. Michael says:

    What would the connection string look like for a CRM Online organization?

  2. Antony Ellis says:

    Hi ,not sure it is exaggerated to be honest. The introduction of Web API is here to replace the existing Organization Service and SOAP endpoints completely. So from Dynamics 365 onwards at least it is truly dead. Talked about it here: http://antonyellisdynamicscrm.wordpress.com/2017/02/20/dynamics-365-crm-sdk-version-comparisons/

Leave a Reply

Your email address will not be published. Required fields are marked *