{Fixed} Metadata contains a reference that cannot be resolved in Dynamics 365 – How to resolve?

Follow Debajit’s Power Apps & Dynamics 365 Blog on WordPress.com

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

 


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

2 thoughts on “{Fixed} Metadata contains a reference that cannot be resolved in Dynamics 365 – How to resolve?”

  1. namespace lvpeiregistration_form
    {
    public partial class WebForm1 : System.Web.UI.Page
    {
    // OrganizationServiceProxy serviceProxy;
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    static IOrganizationService _service;
    protected void button1_Click(object sender, EventArgs e)
    {
    ClientCredentials credentials = new ClientCredentials();
    credentials.UserName.UserName = “*************”;
    credentials.UserName.Password = “**************”;
    Uri serviceUri = new Uri(“https://**********.****.*******/XRMServices/2011/Organization.svc”);
    credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
    Uri HomeRealm = null;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
    OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, HomeRealm, credentials, null);
    {
    _service = (IOrganizationService)proxy;
    Entity contact = new Entity(“contact”);
    contact[“firstname”] = txtFirstName.Text.ToString();
    contact[“lastname”] = txtLastName.Text.ToString();
    contact[“emailaddress1”] = txtEmailAddress.Text.ToString();
    contact[“telephone1”] = txtPhoneNumber.Text.ToString();
    contact[“address1_line2”] = txtstreet.Text.ToString();
    contact[“address2_city”] = txtcity.Text.ToString();
    contact[“department”] = txtsubject.Text.ToString();
    // contact[“new_selectedbranch”] = int.Parse(DropDownList1.Text.ToString());
    // contact[“new_foundyouthrough”] = int.Parse(DropDownList2.Text.ToString());
    contact[“new_followuptext”] = TextBox1.Text.ToString();
    contact[“new_message”] = message.Text.ToString();
    Guid newContactId = _service.Create(contact);
    txtFirstName.Text = “”;
    txtLastName.Text = “”;
    txtEmailAddress.Text = “”;
    txtPhoneNumber.Text = “”;
    txtstreet.Text = “”;
    txtcity.Text = “”;
    txtsubject.Text = “”;
    //DropDownList1 = “”;
    //DropDownList2=””;
    TextBox1.Text = “”;
    message.Text = “”;
    }
    }
    }
    THIS IS THE SOAP API TO PUSH THE DATA TO DYNAMIC CRM COULD PLEASE TELL HOW TO RETRIEVE THE DATA FROM DYNAMIC CRM USING SOAP API.LOOKING FORWARD TO YOUR REPLY.
    THANKING YOU
    WARM REGARDS
    SAIKUMAR PUTTA

Comments are closed.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading