Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Can't connect to my Microsoft Dynamics 365 - CrmServiceClient IsReady keeps returning false

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Recently my (outdated) connection to my Dynamics online environment (Microsoft Dynamics 365 version1612 (9.0.0.3172) (DB 9.0.0.3172) online)  stopped working for some reason.

OLD connection:

  Uri serviceUri = new Uri(SoapOrgServiceUri);
                OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null)

I was advised to use a newer connection found on the following links:

msdn.microsoft.com/.../jj602970.aspx

https://msdn.microsoft.com/en-us/library/dn688177.aspx

So I tried to implement one of these connections, but after multiple tries and using different connection setups, they all seem to be returning False on the IsReady state of the CrmService client. I am probably doing something wrong but I can't figure out what. 

The code used to connect to my CRM (tried more but deleted most of those tries): 

Example 1:

String connectionString = GetServiceConfiguration();

CrmServiceClient m_CrmServiceClient = new CrmServiceClient(connectionString);





private static String GetServiceConfiguration()
        {
            // Get available connection strings from app.config.
            int count = ConfigurationManager.ConnectionStrings.Count;


            // Create a filter list of connection strings so that we have a list of valid
            // connection strings for Microsoft Dynamics CRM only.
            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));
            }

            // No valid connections strings found. Write out and error message.
            if (filteredConnectionStrings.Count == 0)
            {
                return null;
            }

            // If one valid connection string is found, use that.
            if (filteredConnectionStrings.Count == 1)
            {
                return filteredConnectionStrings[0].Value;
            }

            // If more than one valid connection string is found, then return null.
            if (filteredConnectionStrings.Count > 1)
            {
                return null; 
            }
            return null;

        }


The connection string used :

<add name="Server=CRM Online, organization=hulten, user=nicolas" connectionString="Url=hulten.crm4.dynamics.com; Username=nicolas@xxxx.com; Password=xxxx; authtype=Office365" />


This  returns the following error on debugging (which can be ignored right?):

6675.ErrorCrm.PNG

And it returns false on the IsReady property of the CrmServiceClient.

Example2:

CrmServiceClient crmSvc = new CrmServiceClient("nicolas@xxxx.com", CrmServiceClient.MakeSecureString("xxxx"), "Europe", "hulten", useUniqueInstance:false, useSsl:false, isOffice365:true);


Same issue here, also return false on IsReady.

Goal of application

The goal I want to achieve is simple, use a function in my web application (C#, .Net 4.6.2) which inserts data into my CRM environment. 

Details of my environment / additional information

Dynamics version: Microsoft Dynamics 365 version1612 (9.0.0.3172) (DB 9.0.0.3172) online

C# application: Web, targeting framework = .Net 4.6.2

Xrm SDK tool / Tooling / Crm SDK Proxy versions : All updated to 9.0.0.2 (latest)

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Used before connecting (suggested as fix in several posts).

My credentials used are fine (I can login into dynamics) and I have admin rights. 

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can't connect to my Microsoft Dynamics 365 - CrmServiceClient IsReady keeps returning false

    After trying multiple things pointed out in other psots I ended up creating a new project and it seems to work in there..

    One big help was that in your config connection URL you dont use your company name but the unique ID of your company :

    Not :

    connectionString="Url=https://hulten.crm4.dynamics.com; Username=nicolas@xxxx.com; Password=xxxx; authtype=Office365" 


    But :
    connectionString="Url=https://uniqueID.crm4.dynamics.com; Username=nicolas@xxxx.com; Password=xxxx; authtype=Office365" 

    Unique ID is found in developer resources in your dynamics environment.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can't connect to my Microsoft Dynamics 365 - CrmServiceClient IsReady keeps returning false

    My bad I am already using  9.0.0.7 (the 2 was a typo)

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,069 Super User 2024 Season 1 on at
    RE: Can't connect to my Microsoft Dynamics 365 - CrmServiceClient IsReady keeps returning false

    the latest nuget packages are 9.0.0.7

    make sure your connection string contains AuthType and not authtype as you posted, also https is missing from your url.

    You can also try with a new c# console application (4.6.2) and just using

    string myConnectionString = "AuthType='Office365'; Url='hulten.crm4.dynamics.com'; Username='nicolas@xxxx.com'; Password='xxxx';";
    CrmServiceClient service = new CrmServiceClient(myConnectionString);
    WhoAmIResponse whoAmIResponse = (WhoAmIResponse)service.Execute(new WhoAmIRequest());
    Console.WriteLine(whoAmIResponse.UserId.ToString());
  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Can't connect to my Microsoft Dynamics 365 - CrmServiceClient IsReady keeps returning false

    Hello,

    Check LastCrmError and/or LastCrmException properties of CrmServiceClient instance you instantiate.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans