“Error ERROR Validation Error The activity delegate with Handler ‘Body’ cannot be referenced by activity ‘For Each’ because the latter is not in the implementation of activity ‘DynamicActivity’. An activity delegate can only be referenced by the implementation of an activity which specifies that activity delegate as a child or import. The activity delegate with Handler ‘Body’ is declared by activity ‘For Each’. Workflows/PrepararCarpetesPerATeams.xaml”
This is the error I got in a couple ForEach activities after I merely changed the name of a variable involved in it.
The variable name is that one of the collection I’m passing to the loop. Workflows are involved, so the collection gets there via a previous couple of in/out arguments.
After hours of scratching my head, I merely replicated the ForEach activity in the same place, then those errors disappeared. But I noticed:
a) The prior “wrong” activity can’t be erased at all.
b) The “wrong” activity got duplicated, with the new, repliced ForEach loop being placed in the middle of the loop.
The second, duplicated one after the good, “replicated” one, could be erased.
The previous and original one, I could delete part of the innter contents of the activity little by little, but, in the end, it stays inside the surrounding “Sequence” activity but, weirdly, is not attached / connected to any prior or next activity: it’s “unnatached”, not linked to anything, and it can’t get erased.
Amazing bug and amazing the mess I got by merely renaming a var, something I believe is so trivial that should be accomplish automatically for every instance of the variable or every place it’s being used across the “code”. And if it’s not going to be that way, then at least provide a way to refactor a variable, or if not even possible, at least don’t screw up the whole code when attempting a variable rename.
Attaching a screenshot of the “orphan”, unlinked activity.