Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Cannot connect to on-premise CRM using CrmServiceClient

Posted on by 55

Hi Members,

Can someone advise what I am missing in my code here in C#. But unable to connect to CRM. I am currently trying to configure this connectivity in my local environment.

string userName = "domain1\\user1";
string password = "test123";
string orgName = "hypernation.crm365.com/.../Organization.svc";
string internalurl = "hypernation.crm365.com";
NetworkCredential creds = new NetworkCredential(userName, CrmServiceClient.MakeSecureString(password));
Microsoft.Xrm.Tooling.Connector.AuthenticationType authType = Microsoft.Xrm.Tooling.Connector.AuthenticationType.AD;

CrmServiceClient conn = new CrmServiceClient(creds, authType, internalurl, "443", orgName, true, true, null);

I tried using connection string but no luck at all.

<add name="crm"
connectionString="AuthType=AD;Url=hypernation.crm365.com/.../Organization.svc; Domain=domain1; Username=domain1\user1; Password=test123;"/>

Here above is there any other alternative to configure connection string?
My main motive is to use the flag "RequireNewInstance=true". but can't seem to use it without CrmServiceClient instance.

I am able to connect to CRM using OrganizationServiceProxy class and can access entities fluently.

Thank you.

*This post is locked for comments

  • Prashant D Profile Picture
    Prashant D 12 on at
    Cannot connect to on-premise CRM using CrmServiceClient
    Thanks, it worked like charm.
  • Verified answer
    binoyk Profile Picture
    binoyk 55 on at
    RE: Cannot connect to on-premise CRM using CrmServiceClient

    Not everyone can be wrong.

    I re-read the whole articles and list of parameters and found that my "Url" parameter was the issue.

    docs.microsoft.com/.../mt608573(v=crm.8)

    My correct connection string becomes like below:

    <connectionStrings>

       <!-- On-premises using Windows integrated security -->

       <add name="CRMConnectionString"

            connectionString="Url=hypernation.crm365.com/hypernation; Username=domain1\user1;Password=test123;Domain=domain1;AuthType=AD;RequireNewInstance=true;"/>

     </connectionStrings>

    </configuration>

  • binoyk Profile Picture
    binoyk 55 on at
    RE: Cannot connect to on-premise CRM using CrmServiceClient

    Thanks Ravi for your response.

    I visited both the links and especially Carl's. What he advised I did that way but no luck. Honestly no matter whatsoever thing mentioned in this link i try I am not able to connect using CrmServiceClient. it always shows "IsReady" = false.

    To answer your question. No, it is not IFD environment. It is on-premise.

    Error message I am receiving is Unable to connect Dynamics CRM.

    As I am able to connect using OrganizationServiceProxy, I know I can pass that proxy instance to initialize CrmServiceClient instance but how do I use RequireNewInstance=true property ? (this is my prime requirement)

    Somehow I don't know to tweak the code to use it.

    Please advise.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Cannot connect to on-premise CRM using CrmServiceClient

    Hi,

    You can find all combination with respect to the specifis type of environment in the below link-

    docs.microsoft.com/.../mt608573(v=crm.8)

    You can refer this blog as well: carldesouza.com/connecting-to-dynamics-365-using-crmserviceclient

    Is it an IFD environment? What is the error you are getting when using CRMServiceClient? If you are able to connect using OrganizationServiceProxy , any specific reason you want to use CRMServiceClient?

    Hope this helps.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,961 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,443 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans