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)

Issue while creating concurrent instances of IOrganizationService service

(0) ShareShare
ReportReport
Posted on by 390

Hi,

We are having a performance issue in our CRM 2011 due to no of concurrent instances created for IOrganizationService service.

We have CRM 2011 installed with IFD ADFS configuration. There are around 100 users using the CRM application.

Our client will organize and manage Events in CRM.

We have a separate web portal for allowing public users to register for the events in CRM. Its a ASP.NET web application with forms authentication. The portal will create an instance of IOrganizationService and retrieve the events from CRM and display in the portal. Then the user will select some events and click the submit to register for the events. the registration is recorded in CRM. So all the retrieve, cerate, update is happening through IOrganizationService instance.

Now the problem is when the no if users using the portal is high the portal becomes very slow or even sometimes throw an error when creating an instance for IOrganizationService. It throws error as "Metadata contains a reference that cannot be resolved". This happens only when the no of users using the portal is very high. This also affects the CRM application performance.

Please advice on how to proceed with this issue. I knew IOrganizationService is not thread safe so for each update, create, delete new instance is created for a single session. So for 5000 users there will be 20,000 instances of IOrganizationService created approximately. Is this the correct way to handle the IOrganizationService. Is there any limit for the no of instances for IOrganizationService. As I said after certain limit the application throws error while initiating the IOrganizationService object. The application is accessible intermittently. Please help of how to resolve the issue.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi - the Xrm.Client library is designed for portals and uses connection pooling for performance - see my blog series - develop1.net/.../MicrosoftXrmClient-Part-1.aspx

    Hope this answers your question?

  • Jayakumar Profile Picture
    390 on at

    Hi Scott,

    We are using this method to create instance of Organization Service. How to use connection pool here.

    ----Code----

    Uri OrganizationURI = new Uri(ConfigurationManager.AppSettings["OrganizationUri"]);

    string publicCode = ConfigurationManager.AppSettings["Code"];

    string Username = ConfigurationManager.AppSettings.Get("UserName");

    string Password = ConfigurationManager.AppSettings.Get("Password");

    string Domain = ConfigurationManager.AppSettings.Get("Domain");

    ClientCredentials _Credential = new ClientCredentials();

    _Credential.UserName.UserName = Username + "@" + Domain;

    _Credential.UserName.Password = Password;

    using (OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(OrganizationURI, null, _Credential, _Credential))

    {

    // This statement is required to enable early-bound type support.

    _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

    _service = (IOrganizationService)_serviceProxy;

    }

    return _service;

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    You can't connection pool using the OrganizationServiceProxy - you need to use the Microsoft.Xrm.Client library

    using (OrganizationService proxy = new OrganizationService(CrmConnection.Parse(connectionString)))

    {

  • Jayakumar Profile Picture
    390 on at

    Hi Scott,

    This worked for  me.

    static CrmConnection crmConnect = CrmConnection.Parse(@"ServiceUri=https://CRMHost;Username=crmuser;Password=password;");

    crmConnect.ProxyTypesEnabled = true;

    crmConnect.Timeout = new TimeSpan(0, 0, 60, 0);

    OrganizationService orgService = new OrganizationService(crmConnect);

    return orgService;

    Thanks.

    Jayakumar

  • Jayakumar Profile Picture
    390 on at

    Hi Scott,

    Since my portal is open to public users many users will be using parallel. To achieve the scalability how should I inititate the CRM connection. Do I need to initiate the CRMConnection as static so that the connection is initiated only once and shared for all users to create instance of OrganizationService.

    1. Declare CrmConnection as static and initiate once for the app domain.

    2. New instance of OrganizationService will be created for each operation but will use the Shared CrmConnection to create instance.

    Is this correct or do I need to create a new CrmConnection for each user logged into our portal?

    Thanks.

    Jayakumar

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