Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Unable to connect SDK metadata code to the ms crm online

Posted on by 225

I tried by passing all the related url for example:trasfer.crm8.dynamics.com:443 and 444 ,8085 in console application, i am getting the error metadata contains a reference that cannot be resolved and not able to connect to the online ms crm, please any body suggest me.

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    Hi

    You could download my sample application from my following github page and test and see if this works for you.

    This sample project has all the libraries referenced

    github.com/.../CRMServiceClientQuickStart

  • Amrutha B K Profile Picture
    Amrutha B K 225 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    Actually, i tried by connecting to online ms crm it is connecting by using a console application in one system but not in another system,please any body suggest me.

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    Hi Amrutha,

    Please refer below code its working for me on both type of instance:

       public static String GetServiceConfiguration()

       {

           int count = ConfigurationManager.ConnectionStrings.Count;

           List<KeyValuePair<String, String>> filteredConnectionStrings =

               new List<KeyValuePair<String, String>>();

           for (int a = 0; a < count; a++)

           {

               if (isValidConnectionString(ConfigurationManager.ConnectionStrings[a].ConnectionString))

                   filteredConnectionStrings.Add

                       (new KeyValuePair<string, string>

                           (ConfigurationManager.ConnectionStrings[a].Name,

                           ConfigurationManager.ConnectionStrings[a].ConnectionString));

           }

           if (filteredConnectionStrings.Count == 0)

           {

               Console.WriteLine("An app.config file containing at least one valid Microsoft Dynamics CRM " +

                   "connection string configuration must exist in the run-time folder.");

               Console.WriteLine("\nThere are several commented out example connection strings in " +

                   "the provided app.config file. Uncomment one of them and modify the string according " +

                   "to your Microsoft Dynamics CRM installation. Then re-run the sample.");

               return null;

           }

           if (filteredConnectionStrings.Count == 1)

           {

               return filteredConnectionStrings[0].Value;

           }

           return null;

       }

       private static Boolean isValidConnectionString(String connectionString)

       {

           if (connectionString.Contains("Url=") || connectionString.Contains("Server=") || connectionString.Contains("ServiceUri="))

               return true;

           return false;

       }

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    Hi Amrutha,

    Please refer below code its working for me on both type of instance:

    public static IOrganizationService service;

       //DLL reference

       //using Microsoft.Xrm.Sdk.Client;

       //using System.ServiceModel.Description;

       //using System.Net;

       //using Microsoft.Xrm.Sdk.Query;

       //using Microsoft.Xrm.Sdk.Messages;

       //using Microsoft.Crm.Sdk.Messages;

       //using Microsoft.Xrm.Client.Services;

       //using Microsoft.Xrm.Client;

       public void MethodName()

       {

           ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

           Microsoft.Xrm.Client.CrmConnection connection = CrmConnection.Parse(GetServiceConfiguration());

           service = new OrganizationService(connection);

           {

               //Your code here

           }

       }

       public static String GetServiceConfiguration()

       {

           int count = ConfigurationManager.ConnectionStrings.Count;

           List<KeyValuePair<String, String>> filteredConnectionStrings =

               new List<KeyValuePair<String, String>>();

           for (int a = 0; a < count; a++)

           {

               if (isValidConnectionString(ConfigurationManager.ConnectionStrings[a].ConnectionString))

                   filteredConnectionStrings.Add

                       (new KeyValuePair<string, string>

                           (ConfigurationManager.ConnectionStrings[a].Name,

                           ConfigurationManager.ConnectionStrings[a].ConnectionString));

           }

           if (filteredConnectionStrings.Count == 0)

           {

               Console.WriteLine("An app.config file containing at least one valid Microsoft Dynamics CRM " +

                   "connection string configuration must exist in the run-time folder.");

               Console.WriteLine("\nThere are several commented out example connection strings in " +

                   "the provided app.config file. Uncomment one of them and modify the string according " +

                   "to your Microsoft Dynamics CRM installation. Then re-run the sample.");

               return null;

           }

           if (filteredConnectionStrings.Count == 1)

           {

               return filteredConnectionStrings[0].Value;

           }

           return null;

       }

       private static Boolean isValidConnectionString(String connectionString)

       {

           if (connectionString.Contains("Url=") || connectionString.Contains("Server=") || connectionString.Contains("ServiceUri="))

               return true;

           return false;

       }

       //<configuration>

       // <connectionStrings>

       // <add name= "Xrm" connectionString = "Url=crmdomainname.crm11.dynamics.com; Username=yourusername; Password=Userpassword; authtype=Office365" />

       //</connectionStrings>

       //</configuration>

  • Amrutha B K Profile Picture
    Amrutha B K 225 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    Its working for the onpremise ms crm ,but not for ms crm online version.

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    Check below post. It may help you:

    community.dynamics.com/.../219620

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Unable to connect SDK metadata code to the ms crm online

    share your code

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans