Break: Unable to cast object of type 'System.String' to type 'System.Activities.Bookmark'

Anyone ever had this error thrown on a Break activity?

Before you ask, yes, it is in a for-each loop activity.

1 Like

@edevries

Never faced this issue but is it happening while design time or runtime.

Also how to reproduce the issue.

1 Like

@edevries

Can you please elaborate on when it happened and is it one time or recurring?

on break ideally you would not send anything as input also this is strange.

cheers

1 Like

Check your For Each activity:

  • If it says UiPath.Framework.ForEach,
    Break will NOT work.
  • Replace it with the normal UiPath.Core.Activities.ForEach
    Break will work correctly.

This fixes the issue in almost all cases.

If you want, send a screenshot of your For Each activity and I’ll confirm which one you are using.

1 Like

It reoccurs every time I run, so consistent

Reoccurring, I was able to recreate it the same way multiple times.

Hi @edevries

Strange, You can check For Each might be TypeArgument set incorrectly…
If yes Try to set the TypeArgument of the For Each to the correct type, usually string.

Happy Automation

@edevries

Is it thrown on break only

can you run in debug and show locals panel results when error occurs

cheers


Also happens on continues

Same error. Also, currentBOLPath, which is the item in the collection we are iterating over is the string that is expected in the local panel

I am just going to rebuild the activities. I made a new for each loop activity for the same collection with a break activity in it and it worked.

1 Like

Sounds good, it worked for you.