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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Using Multiple OrganizationServices for multiple instances of Dynamics CRM Online (.Net XRM SDK)

(0) ShareShare
ReportReport
Posted on by

Hello, I'm using the SDK to send data from Dynamics into our reporting system. I'm working with two instances of Dynamics CRM Online (xxx.crm.dynamics.com AND yyy.crm.dynamics.com). Right now, I instantiate the OrganizationService for xxx instance, retrieve data then send that data. When I instantiate the organization service for the second instance (yyy) and call for the data from that, I'm receiving data from the first (xxx) instance.

How do I either separate them (so I can call them both concurrently) or throw away the first instance and just use the second instance (synchronous and dirty but I'll take it)? 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: Using Multiple OrganizationServices for multiple instances of Dynamics CRM Online (.Net XRM SDK)

    Hi,
    I think you can use threading for this one.
    For connecting you can refer from Aric Levin post in community.dynamics.com/.../connecting-to-dynamics-crm-from-console-application-part-i

    For threading part something like this:

    var connectionStrings = new[]
                {
                    "Url=internal.contoso.com/.../Organization.svc; Username=contoso\crmadmin; Password=abcdef1234; authtype=IFD",
                    "Url=internal.contoso.com/.../Organization.svc; Username=contoso\crmadmin; Password=abcdef1234; authtype=IFD"
                };
    
                Parallel.ForEach(connectionStrings, (conn) =>
                {
                    //Do instance, retrieve, send data..
                });


    Hope this help!

  • Suggested answer
    unizap Profile Picture
    on at
    RE: Using Multiple OrganizationServices for multiple instances of Dynamics CRM Online (.Net XRM SDK)

    Hi,

    You can try the 'using' statement to achieve this.

    something like following:

    // Connect to the Organization service.

    // The using statement assures that the service proxy will be properly disposed.

    //instance 1

    using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,                                                                     serverConfig.Credentials, serverConfig.DeviceCredentials))

    {

     IOrganizationService _service = (IOrganizationService)_serviceProxy;

     //Perform operations...

     _service.Retrieve(data);

    }

    //instance 2

    using (_serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri,                                                                     Credentials, DeviceCredentials))

    {

     IOrganizationService _service = (IOrganizationService)_serviceProxy;

     //Perform operations...

     _service.Retrieve(data);

    }

  • Community Member Profile Picture
    on at
    RE: Using Multiple OrganizationServices for multiple instances of Dynamics CRM Online (.Net XRM SDK)

    Right now I'm using the CrmServiceClient, and calling it's dispose method and it's OrganizationServiceProxy.Dispose method in the Dispose method of my parent class. This client is easy because I can use a simple connection string. This method you're using is somewhat harder to set up the authentication for Dynamics Online.

  • Community Member Profile Picture
    on at
    RE: Using Multiple OrganizationServices for multiple instances of Dynamics CRM Online (.Net XRM SDK)

    You can have two separate connections with two Crm instances.

    When using the CrmServiceClient Class you must explicit say that you want a unique instance for that object.

    Set useUniqueInstance as true.

    public CrmServiceClient(
          string crmUserId, 
          SecureString crmPassword,  
          string crmRegion, 
          string orgName, 
          bool useUniqueInstance = false, 
          bool useSsl = false, 
          OrganizationDetail orgDetail = null, 
          bool isOffice365 = false
    );

    Ex.:
    var con = new CrmServiceClient(
       user, 
       CrmServiceClient.MakeSecureString(password), 
       "Brazil South", 
       "YOU_ORG_NAME", 
       true, 
       false, 
       null, 
       true);

    Pay attention to your CRM region. Mine is "Brasil South".

    You can find the CRM Region list here.

    Best Regards

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans