Problem
While upgrading a .NET customisation that interfaced with our client Dynamics 365 online environment (Version 9). I encountered the following error while attempting to fetch some records from our Dynamics 365 instance.
The same code had previously worked without issue in our Dynamics 365 Version 8 environment.
“Metadata contains a reference that cannot be resolved: ‘https://XXXX.api.crm6.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=9'.”
{“The underlying connection was closed: An unexpected error occurred on a send.”}
{“Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.”}
“The underlying connection was closed: An unexpected error occurred on a send.”
Solution
As per the below Microsoft article Dynamics 365 now requires TLS 1.2
https://support.microsoft.com/en-au/help/4051700
The solution is to either:
- Use .NET framework version 4.6 which uses TLS 1.2 by default
or
- Add the below line of code to your app (before making calls to Dynamics 365) to explicitly enable TLS 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
- Azure CRON Expression – Cheat Sheet - 14th January 2021
- How To: Win 10 Screen Sharing - 17th December 2020
- How To: Unlock Protected Excel Spreadsheet - 11th November 2020
Leave a Reply