<Fix for Unhandled exceptions while connecting to Dynamics 365 online>
Metadata Diagram, a console application comes with Dynamics 365 SDK is capable of creating entities ER diagram in Visio. You can find sample code and Readme instructions at below location:
SDK\SampleCode\CS\Metadata\Diagram
By default, console creates ER diagram for all entities, but you can pass entity schema names as arguments to restrict it for fewer entities.
- Right click on the MetadataDiagramConsole in the Solution Explorer and select Properties. Click on the Debug section of the properties dialog. Enter: “opportunity account” into the Command Line Arguments textbox to have the application draw only the opportunity and account entities.
Connect to Dynamics 365 OL
While connecting to Dynamics 365 OL, you might face unhandled exceptions as below:
- The server could not be contacted. LDAP server is unavailable
- There was no endpoint listening
- Request timeouts while retrieving metadata
You can fix this issue by simply modifying below red highlighted code in Main() method
try{// Obtain the target organization’s Web address and client logon// credentials from the user.//ServerConnection serverConnect = new ServerConnection();//ServerConnection.Configuration config = serverConnect.GetServerConfiguration();string strUrl = string.Empty;strUrl = “https://<orgname>.api.crm9.dynamics.com/XRMServices/2011/Organization.svc“;ClientCredentials credential = new ClientCredentials();credential.UserName.UserName = “*********.onmicrosoft.com”;credential.UserName.Password = “***************”; // Set security protocol to TLS 1.2 for version 9.0 of Customer Engagement Platform
|
Note – You can define connection URL and credentials in app.config to make it configurable.