{Fixed} Error while connecting to Dynamics 365 Version 9.0–Metadata contains a reference that cannot be resolved.
Recently one of our customers upgraded to Version 9.0 from D365 8.2 and then all of a sudden all the console jobs which used to connect to Dynamics CRM and were scheduled as batch jobs started failing.
Checking the event viewer we found out the following error – “Metadata contains a reference that cannot be resolved”.
Was curious to know and hence copied the portion of code which connects to CRM from batch job, into a separate console application. Sample code below
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = “<username>”;
clientCredentials.UserName.Password = “<password>”;
var proxy = new OrganizationServiceProxy(new Uri(“https://domainname.crm.dynamics.com/XRMServices/2011/Organization.svc”),
null, clientCredentials, null);
<<<code to perform fetch>>>
It was failing while trying to create the proxy. The same code was working in Dynamics CRM version 8.2
Thought something changed in the service URL and hence copied and pasted the URL in the browser. Worked just fine.
So what can be the problem here.
So when I opened CRM in browser (firefox in this case), I just clicked on the padlock to view the certificate information and then click on More Information (shown in screenshots below).
In the technical details I could see the Encryption protocol being used is TLS1.2
Just our of curiosity, I just added the below line of code before creating the proxy.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Full code.
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = “<username>”;
clientCredentials.UserName.Password = “<password>”;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var proxy = new OrganizationServiceProxy(new Uri(“https://domainname.crm.dynamics.com/XRMServices/2011/Organization.svc”),
null, clientCredentials, null);
And voila it worked just fine.
I am still researching as to why I needed to use this in version 9.0 although TLS 1.2 was being used in the previous versions as well.
Hope this helps to resolve the issue and save some time.
-Debajit Dutta (Dynamics MVP)
For training/ consulting please visit www.xrmforyou.com
This was originally posted here.

Like
Report
*This post is locked for comments