Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Cannot connect to on-premise CRM using CrmServiceClient

(0) ShareShare
ReportReport
Posted on by 57

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 17 on at
    Cannot connect to on-premise CRM using CrmServiceClient
    Thanks, it worked like charm.
  • Verified answer
    binoyk Profile Picture
    binoyk 57 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 57 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

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 Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,605 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans