Ben Walker
  • Blog
  • Blog

Creating an OrganizationService connection to Dynamics 365 Online v9.0

15/6/2018

0 Comments

 
I recently tried to use the sample code in the Dynamics 365 SDK (also available here) to create a connection in code to the Dynamics CRM v9 Organisation service. No matter what I did, I could not get the sample code to work.
I was just getting a 'System.NullReferenceException' error, and the only other clue was that the connection object's LastCrmError property had a value of "Unable to Login to Dynamics CRM Organization Web Proxy Client is null:
Picture
After a significant amount of head-scratching, a colleague reminded me that Microsoft have recently announced that connections to Dynamics 365 v9 will only work if using TLS 1.2 or higher.
Once we’d established this was the problem, fixing the issue was quite easy: before creating the connection to CRM, you need to switch to using TLS 1.2, which can be done like this:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using the ServicePointManager in System.Net.
Until Microsoft update their sample code to include this, I hope that this saves someone the problems I had in getting the connection to work.
With thanks to Ian Cummings for helping me to resolve this issue!

0 Comments



Leave a Reply.

    Archives

    July 2021
    June 2021
    May 2020
    March 2020
    December 2019
    October 2019
    June 2018
    February 2018
    October 2017
    September 2017
    August 2017
    May 2017
    April 2017

    Categories

    All
    Dynamics 365
    Dynamics CRM
    FakeXrmEasy
    LINQPad
    Testing

    RSS Feed

    Author

    Some stuff about me!

Proudly powered by Weebly