Array index out of bounds/disposed exception

Hi,

I am facing below error while assigning values to a string array second time in a loop.

It works fine first time but then second time, throws this error.

Its an assign statment like below:

Arr = li.toString().Split(","c).Select(Function (x,i) arrCols(i) + “:” + x).toArray

when I checked the output of below statement, it says " SelectIterator { ! … }"
li.toString().Split(","c).Select(Function (x,i) arrCols(i) + “:” + x)

RemoteException wrapping System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Namespace_869d.ConnectSharepointwithPA_Expressions.ConnectSharepointwithPA_Expressions_TypedDataContext6_ForReadOnly._Lambda$__28-0(String x,
Int32 i)
at System.Linq.Enumerable.SelectIterator[TSource,TResult](IEnumerable1 source, Func3 selector)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at Namespace_869d.ConnectSharepointwithPA_Expressions.ConnectSharepointwithPA_Expressions_TypedDataContext6_ForReadOnly.__Expr44Get() at Namespace_869d.ConnectSharepointwithPA_Expressions.ConnectSharepointwithPA_Expressions_TypedDataContext6_ForReadOnly.ValueType___Expr44Get() at Namespace_869d.ConnectSharepointwithPA_Expressions.InvokeExpression(Int32 expressionId, IList1 locations,
ActivityContext activityContext)
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity)
at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor) at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides,
Location resultLocation,
Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor,
IDictionary`2 argumentValueOverrides,
Location resultLocation,
Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)

1 Like

@sonaliaggarwal47

the issue likely is due to arrCols(i)..think like after splitting with comma say li has 3 items and arrcols has only 1 then it would fail

so first split and check what are you getting…and what is li? is it a list?

cheers

@Anil_G

Li is the current listitem. It has only 1 item at the moment.

And I had tested this workflow in the past for 2 items, it ran fine.

Today, suddenly it’s throwing error at 2nd item every single time

@sonaliaggarwal47

what is array col…and when you split did you check if it is generating one or two or more values…as split is on comma depends on how many are there

break the statement
check the split count in locals and compare with arrcol size

cheers

@Anil_G

There are almost 10 different values there and I have already defined/jnitialized array(arrcols) with those different column names.

So trying to do 1:1 mapping here

But I will try to have more detailed look at the values and see if anything else is coming in.

@sonaliaggarwal47

The only thing you need to verify is when it errors out

Hope that will shed more light into issue

Cheers

Found the issue.

In one of the columns for that particular list item, additional comma was coming which after split was leading to more number of columns than the number of columns defined for Array.

Hence, the issue.

Once, I got that column value fixed in the backend, it worked.

Thanks for the help :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.