How to Connect to Microsoft Dynamics 365 Version 9 in C#

Adam Murchison, 21 May 2018

Have you tried to connect to a CRM via C# and gotten the following error:

image

The reason this occurs is because CRM have updated their requirements to connect to their services. The requirement is to set the Security Protocol property to TLS1.2 or (Transport Layer Security Protocol 1.2).

You can simply develop on .Net 4.6.x which will default to TLS1.2 but if you’re developing on 4.5.x then you would need to manually set the transport protocol to TLS1.2 before you send the connection request.

To do this is as follows:
  image

It’s as easy as that.

Reasoning Behind Microsoft Updating Their Protocol Requirements

In previous versions of CRM, you could connect using the transport protocol TLS 1.0. The transport protocol is a communications protocol which is used to establish a safe connection and then ensure that the data can be transferred between the parties safely.

TLS 1.0 is secure if the person implementing this protocol has a non-predictable IV (Initialization Vector). TLS 1.1 and 1.2 have improved on this by mitigating implementation flaws by use of explicit vectors.