Linq Select breaks when using variable to create items

I observed this problem when using a variable to create a list of items.
In the attached example an integer is assigned to 1, then an enumerable is assigned by Selecting on a list, which should just generate a list of 1s.
The Log statement now crashes with a really weird error message:

Blockquote Log message : Activity ‘1.3: VisualBasicValue’ cannot access this public location reference because it is only valid for activity ‘1.8: VisualBasicValue<IEnumerable>’. Only the activity which obtained the public location reference is allowed to use it.

The fix is to force the Select to evaluate immediately by calling .ToArray on the resulting Enumerable, but I am wondering why this is even a problem? I can not replicate the problem in C#, only in UiPath.

UIPathError.xaml (7.7 KB)

1 Like