Something is wrong with latest Studio or one of the dependencies

I keep getting this error every once in a while. It corrupts the XAML file, duplicates the offending activity, and I have to close, reopen, and then delete the duplicates and it’s OK. It seems it is always a For Each that gets corrupted. I think it’s related to the new “dynamic activity” thing.

This is not happening when running the automation. It’s happening while I’m in Studio writing code.

Studio 2021.10.5

image

The possible reason is that you are using Excel Application scope, which is not stable when Excel file is large.

What you can do is to get SheetArray using Excel Application scope and then close it.

Then use File->Workbook->Read Range to read each worksheet.

try keeping delays between each for each, As it is inside the excel application scope so thats why it need time to close and reopen the file

It’s not happening when the automation is running. It’s happening when I’m coding in Studio. All of a sudden it’ll pop up all those errors and I have to fix it.

This morning it happened again when I was trying to publish. I look and the same For Each is duplicated over and over again.

When trying to delete them I get…

image

21.10.5+Branch.support-v21.10.Sha.369f46199a0fa6287d86ab2534b6896019db01bc

removeIndex is less than zero or greater than or equal to Count.

Error: System.Exception: removeIndex is less than zero or greater than or equal to Count.
at MS.Internal.Controls.InnerItemCollectionView.RemoveAt(Int32 index)
at System.Windows.Controls.ItemCollection.RemoveAt(Int32 removeIndex)
at System.Activities.Presentation.WorkflowItemsPresenter.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Activities.Presentation.Model.ModelItemCollectionImpl.RemoveCore(ModelItem item)
at System.Activities.Presentation.Model.CollectionChange.ApplyDelete()
at System.Activities.Presentation.Model.CollectionChange.Apply()
at System.Activities.Presentation.Model.EditingScope.OnComplete()
at System.Activities.Presentation.Model.ModelEditingScope.Complete()
at UiPath.Studio.Plugin.Workflow.WorkflowHandling.DeleteHelper.Delete(EditingContext context)
at UiPath.Studio.Plugin.Workflow.WorkflowHandling.DesignerDeleteCommandOverride.OnCommandExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler), HResult -2146233086

Sorry that I have no idea on the errors. Can you create another project to duplicate your current project? BTW, why you repeat For Each several times?

I don’t. As I said, Studio does that when the error occurs. I go to the activity where the error occurred and the activity has been duplicated multiple times.

It keeps duplicating my For Each activities and blowing everything up! I think I figured out that it happens when you change the TypeArgument for a For Each.

@loginerror

I see. It is very weird.

I suggest you to recreate a new project to try. Sorry that I could not figure out the reason. You can escalate the issue to UiPath helpdesk if the issue is still there with newly created project.

Hi @postwick

Strange. Let us know if you manage to reproduce it. I pushed it to our issue tracker in the meantime.

I tried to reproduce it myself and didn’t manage to do that, but it has almost certainly to do with that dynamic For Each capability.

Could you maybe share the data type of the For Each loop?

This particular one is currently String. What happened is I changed the “In” definition to something else, and it dynamically changed the TypeArgument. I changed it back to String and that seems to be what caused it to burp and duplicate the activity repeatedly.

Thank you for more information. It actually happened to me as well in one of my projects, but I cannot reproduce it every time. I’ll keep trying to hunt it down.

1 Like

It has happened to me repeatedly and it seems it’s always when I change the variable for the “In” property which causes the For Each to try to change to a new datatype automatically.