locked
Casting ICrmService to CrmService RRS feed

  • Question

  • Hello All,

    We are getting timeout error while updating the multiple records and found in which entity we are getting the timeout. So, planned to increase the timeout through plugin in that particular entity while performing the actions.

    We created ICrmService and there is no timeout property in ICrmService. Hence we tried to cast ICrmService with CrmService as shown below.

    Dim service As ICrmService = context.CreateCrmService(False)

    DirectCast(service, CrmService).Timeout = 300000

    But while accessing the message as Unable to cast object of type 'Microsoft.Crm.Extensibility.SdkTypeProxyCrmServiceWrapper' to type 'Microsoft.Crm.SdkTypeProxy.CrmService'.

    Can any one help me please to fix the issue.

    Thanks in advance.

    Regards,

    Kumar R

    Tuesday, June 26, 2012 8:07 AM

Answers

  • There is a limit to the time a synchronous plugin is allowed to execute. Therefore consider moving to an asynchronous plugin, a workflow combined with custom activities or another background process.

    Henk van Boeijen

    • Marked as answer by R.A.Kumar Friday, October 12, 2012 1:34 PM
    Tuesday, June 26, 2012 7:15 PM

All replies

  • It's not possible to cast ICrmService to CrmService. I don't know of a programmatic way to increase the timeout on ICrmService, but you could try changing the httpRuntime\executionTimeout value in web.config

    However, I'd suggest you look at why the operation takes so long to execute, and try and reduce the execution time, rather than increasing timeouts. As you're using the Crm 4 endpoint, you can only update one record per request, which shouldn't take so long as to cause a timeout. Are you sure you're not causing an infinite loop somewhere ?


    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk


    Tuesday, June 26, 2012 8:30 AM
    Moderator
  • Hello David,

    Thanks for your update. Yes, we are sure that there is no infinite loop.

    Thanks

    Kumar R

    Tuesday, June 26, 2012 9:28 AM
  • There is a limit to the time a synchronous plugin is allowed to execute. Therefore consider moving to an asynchronous plugin, a workflow combined with custom activities or another background process.

    Henk van Boeijen

    • Marked as answer by R.A.Kumar Friday, October 12, 2012 1:34 PM
    Tuesday, June 26, 2012 7:15 PM