System.InvalidCastException error

I am getting the following error. Please help

20.10.4+Branch.master.Sha.6a6cfd6dfbeb86aec47564af2f9465ef0bf43df4

Source: For Each

Message: Unable to cast object of type ‘System.Text.RegularExpressions.Match’ to type ‘System.Collections.Generic.IEnumerable`1[System.Text.RegularExpressions.Match]’.

Exception Type: System.InvalidCastException

RemoteException wrapping System.InvalidCastException: Unable to cast object of type ‘System.Text.RegularExpressions.Match’ to type 'System.Collections.Generic.IEnumerable1[System.Text.RegularExpressions.Match]'. at UiPath.Core.Activities.ForEach1.InternalExecute(NativeActivityContext context, IEnumerator valueEnumerator)
at UiPath.Core.Activities.ForEach`1.StartLoop(NativeActivityContext context)
at UiPath.Core.Activities.InterruptibleLoopBase.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Can you share the part of the code this error is throwing?

You are passing the incorrect TypeArgument into your for each activity.

Hi @nitish.bakshi
You are trying to cast the value from one data type to other data type in a wrong way( in for each)

Thanks

Could you please guide how and where exactly to correct the same?
I have recently started using Studio

Hi @nitish.bakshi
image

please check this argument

If possible kindly share screenshot of yours

1 Like

Hi @nikhil.girish. Got it working after converting it to string typeargument. Thanks a lot for helping.

Hi @nitish.bakshi please mark this as solution and close this topic

Thanks

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