CrmServiceClient Last known error : One or more errors occurred. => An error occurred while sending the request. => The underlying connection was closed: An unexpected error occurred on a send. => Authentication failed because the remote party has closed the transport stream.ERROR REQUESTING Token FROM THE Authentication context ERROR REQUESTING Token FROM THE Authentication contextNeed a non-empty authority Parameter name: AuthorityUnable to connect to CRM: Need a non-empty authority Parameter name: Authority Need a non-empty authority Parameter name: AuthorityUnable to Login to Dynamics CRM Unable to Login to Dynamics CRM
2 Answers
One will see this error because of TLS. I was stuck with the online connectivity. I created a reusable library in .Net Framework 4.7.2. It works great from my unit test projects. When I imported it as a NuGet package in my actual project, I keept seeing the above error, it work good for On-premise with AuthyType "AD" but failed to connect CRM online.
The reason behind this is my current project runtime targetframework is set to 4.5.2. After changing it to it started working as expected. Reference links: 1) https://support.microsoft.com/en-us/help/4051700 2) https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/383948/client-secret-connection-string-for-sdk-access

- 31
- 6
-
Encountering this error due to a TLS issue is possible even when targeting .NET 4.7+. In that case, [this](https://stackoverflow.com/a/74738094/1667351) answer may help. – Tawab Wakil Dec 09 '22 at 01:58
This has worked in my case
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

- 579
- 6
- 22