locked
Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array from CRM 2011 Plugins RRS feed

  • Question

  • Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array from Plugins

    I am getting the following below from time to time. Not sure how to fix it. If I reset IIS then it starts working again.

    Plugin Trace:

    [MY_Plugins: MY_Plugins.BatchPostFinancialInstrumentsTrxUpdate]
    [074182e3-2888-e111-8674-0050569d49a5: MY_Plugins.BatchPostFinancialInstrumentsTrxUpdate: Update of MY_batch]
    Before oFinancialInstrTrx.UpdateFinancialInstrumentTransactionIntegrationAPI
    Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
    at System.Collections.Generic.List`1.get_Item(Int32 index)
    at System.Collections.Generic.KeyedByTypeCollection`1.Find[T](Boolean remove)
    at System.ServiceModel.Dispatcher.TransactionValidationBehavior.ValidateTransactionFlowRequired(String resource, String name, ServiceEndpoint endpoint)
    at System.ServiceModel.Dispatcher.TransactionValidationBehavior.System.ServiceModel.Description.IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
    at System.ServiceModel.Description.ServiceEndpoint.Validate(Boolean runOperationValidators, Boolean isForService)
    at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
    at System.ServiceModel.ChannelFactory.CreateFactory()
    at System.ServiceModel.ChannelFactory.OnOpening()
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    at System.ServiceModel.ChannelFactory.EnsureOpened()
    at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
    at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.CreateChannel()
    at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.ConfigureNewChannel()
    at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.get_Channel()
    at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer`1.Initialize(ServiceProxy`1 proxy)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceContextInitializer..ctor(OrganizationServiceProxy proxy)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
    at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func`2 action)
    at Microsoft.Xrm.Client.Services.CachedOrganizationService.InnerExecute(OrganizationRequest request)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.InnerExecute[TRequest,TResponse,TResult](TRequest query, Func`2 execute, Func`2 selector)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.<>c__DisplayClass6`3.<LookupAndInsert>b__4(ObjectCache cache)
    at Microsoft.Xrm.Client.Caching.ObjectCacheManager.<>c__DisplayClass9`1.<Get>b__8(String key)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.<>c__DisplayClass5`1.<Get>b__3(Mutex _)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.Lock(String key, Int32 millisecondsTimeout, Action`1 action)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Int32 millisecondsTimeout, Func`2 loadFromCache, Func`2 loadFromService)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Func`2 loadFromCache, Func`2 loadFromService)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.LookupAndInsert[TRequest,TResponse,TResult](TRequest query, Func`2 execute, Func`2 selector, String selectorCacheKey)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.InnerExecute[TRequest,TResponse,TResult](TRequest request, Func`2 execute, Func`2 selector, String selectorCacheKey)
    at Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest request, Func`2 selector, String selectorCacheKey)
    at Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest request)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.RetrieveEntityCollection(OrganizationRequest request, NavigationSource source)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute(QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups, String& pagingCookie, Boolean& moreRecords)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression)
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at MY.BusinessObjects.FinancialInstTrxService.UpdateFinancialInstrumentTransactionIntegrationAPI(Guid batchId, IOrganizationService service)
    at MY_Plugins.BatchPostFinancialInstrumentsTrxUpdate.Execute(IServiceProvider serviceProvider)


    Error Message:

    Unhandled Exception: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Index was outside the bounds of the array.
    at Microsoft.Crm.Asynchronous.EventOperation.CreateAsyncResultFromException(AsyncExecutionContext context, Exception e)
    at Microsoft.Crm.Asynchronous.EventOperation.InvokePlugin(AsyncExecutionContext context, IPlugin pluginInstance)
    at Microsoft.Crm.Asynchronous.EventOperation.InternalExecute(AsyncEvent asyncEvent)
    at Microsoft.Crm.Asynchronous.AsyncOperationCommand.Execute(AsyncEvent asyncEvent)
    at Microsoft.Crm.Asynchronous.QueueManager.PoolHandler.ProcessAsyncEvent(AsyncEvent asyncEvent)
    Inner Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
    at System.Collections.Generic.List`1.get_Item(Int32 index)
    at System.Collections.Generic.KeyedByTypeCollection`1.Find[T](Boolean remove)
    at System.ServiceModel.Dispatcher.TransactionValidationBehavior.ValidateTransactionFlowRequired(String resource, String name, ServiceEndpoint endpoint)
    at System.ServiceModel.Dispatcher.TransactionValidationBehavior.System.ServiceModel.Description.IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
    at System.ServiceModel.Description.ServiceEndpoint.Validate(Boolean runOperationValidators, Boolean isForService)
    at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
    at System.ServiceModel.ChannelFactory.CreateFactory()
    at System.ServiceModel.ChannelFactory.OnOpening()
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    at System.ServiceModel.ChannelFactory.EnsureOpened()
    at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
    at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.CreateChannel()
    at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.ConfigureNewChannel()
    at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.get_Channel()
    at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer`1.Initialize(ServiceProxy`1 proxy)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceContextInitializer..ctor(OrganizationServiceProxy proxy)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
    at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func`2 action)
    at Microsoft.Xrm.Client.Services.CachedOrganizationService.InnerExecute(OrganizationRequest request)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.InnerExecute[TRequest,TResponse,TResult](TRequest query, Func`2 execute, Func`2 selector)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.<>c__DisplayClass6`3.<LookupAndInsert>b__4(ObjectCache cache)
    at Microsoft.Xrm.Client.Caching.ObjectCacheManager.<>c__DisplayClass9`1.<Get>b__8(String key)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.<>c__DisplayClass5`1.<Get>b__3(Mutex _)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.Lock(String key, Int32 millisecondsTimeout, Action`1 action)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Int32 millisecondsTimeout, Func`2 loadFromCache, Func`2 loadFromService)
    at Microsoft.Xrm.Client.Threading.MutexExtensions.Get[T](String key, Func`2 loadFromCache, Func`2 loadFromService)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.LookupAndInsert[TRequest,TResponse,TResult](TRequest query, Func`2 execute, Func`2 selector, String selectorCacheKey)
    at Microsoft.Xrm.Client.Services.OrganizationServiceCache.InnerExecute[TRequest,TResponse,TResult](TRequest request, Func`2 execute, Func`2 selector, String selectorCacheKey)
    at Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest request, Func`2 selector, String selectorCacheKey)
    at Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest request)
    at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.RetrieveEntityCollection(OrganizationRequest request, NavigationSource source)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute(QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups, String& pagingCookie, Boolean& moreRecords)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](QueryExpression qe, Boolean throwIfSequenceIsEmpty, Boolean throwIfSequenceNotSingle, Projection projection, NavigationSource source, List`1 linkLookups)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression)
    at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression)
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at MY.BusinessObjects.FinancialInstTrxService.UpdateFinancialInstrumentTransactionIntegrationAPI(Guid batchId, IOrganizationService service)
    at MY_Plugins.BatchPostFinancialInstrumentsTrxUpdate.Execute(IServiceProvider serviceProvider)
    at Microsoft.Crm.Asynchronous.V5ProxyPlugin.Execute(IServiceProvider serviceProvider)
    at Microsoft.Crm.Asynchronous.EventOperation.InvokePlugin(AsyncExecutionContext context, IPlugin pluginInstance)

    Friday, June 15, 2012 5:41 PM

All replies

  • Hello,

    Can you place the logic of your code here, so that we can have look into it?

    Thanks.


    Regards, Vishnu Turlapati http://blogs.technet.com/b/tvishnun1/

    Saturday, June 16, 2012 5:57 PM
  • Hi there,

    I'm getting a very similar error here with a CRM 2011 UR7. What I'm doing is to call the OrganizationService.Retrieve() service for a custom entity within the context of an IIS web application.

    The result is the following stacktrace. Do you have any clues where this can come from? For me it seems to be deeply embedded into the CRM SDK/.NET code.

    System.IndexOutOfRangeException: Index was outside the bounds of the array.
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at System.Collections.Generic.KeyedByTypeCollection`1.Find[T](Boolean remove)
       at System.ServiceModel.Dispatcher.TransactionValidationBehavior.ValidateTransactionFlowRequired(String resource, String name, ServiceEndpoint endpoint)
       at System.ServiceModel.Dispatcher.TransactionValidationBehavior.System.ServiceModel.Description.IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint)
       at System.ServiceModel.Description.ServiceEndpoint.Validate(Boolean runOperationValidators, Boolean isForService)
       at System.ServiceModel.Channels.ServiceChannelFactory.BuildChannelFactory(ServiceEndpoint serviceEndpoint, Boolean useActiveAutoClose)
       at System.ServiceModel.ChannelFactory.CreateFactory()
       at System.ServiceModel.ChannelFactory.OnOpening()
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ChannelFactory.EnsureOpened()
       at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
       at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.CreateChannel()
       at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.ConfigureNewChannel()
       at Microsoft.Xrm.Sdk.Client.ServiceChannel`1.get_Channel()
       at Microsoft.Xrm.Sdk.Client.ServiceContextInitializer`1.Initialize(ServiceProxy`1 proxy)
       at Microsoft.Xrm.Sdk.Client.OrganizationServiceContextInitializer..ctor(OrganizationServiceProxy proxy)
       at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveCore(String entityName, Guid id, ColumnSet columnSet)
       at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Retrieve(String entityName, Guid id, ColumnSet columnSet)
       at Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClass10.<Retrieve>b__f(IOrganizationService s)
       at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func`2 action)

    Tuesday, March 18, 2014 1:12 PM
  • Hi,

    Any luck to solve this issue? We have an ASP .Net portals that uses CRM SDK to connect it with. When deployed after some time it throws this exception while communicating with CRM, if we reset IIS problem is resolved. Any guess, whats going on?

    Thursday, August 6, 2015 6:39 AM