web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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
    84,331 Most Valuable Professional on at

    Hello,

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

  • Community Member Profile Picture
    on at

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

  • Verified answer
    Community Member Profile Picture
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans