{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).

image

image

 

image

 

In the technical details I could see the Encryption protocol being used is TLS1.2

image

 

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

 

 

Advertisements

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s