I have an created a LINQ query which goes like this:
For Each rw As DataRow In dt2.Rows
rw("Comments") = (From row In dt1 Where row("INPUT FILENAME").ToString = rw("input_extern_file_name").ToString Select x = row)(0)("A NUMBER").ToString
Next rw
Both dt2 and dt1 are passed in as an argument to a Invoke Code activity where the LINQ is written. There are two tables dt2 refers to this Excel:
dt1 refers to
I was trying to find the the input_extern_file_name in dt2 in dt1’s INPUT FILENAME column, if found I the file name in input_extern_file_name in dt2 in dt1’s INPUT FILENAME column, I want to update the Comments column with the value from A NUMBER column in dt1.
NOTES: Some may notice that it is similar to another query found in one of the other posts. Yes this a modification of that query. If my query is wrong please help me to correct it.
Now back to original question, I am tried running this query in this code:
SearchForMissingFiles.xaml (7.9 KB)
However I am getting this error message:
Source: Invoke code
Message: Exception has been thrown by the target of an invocation.
Exception Type: System.Reflection.TargetInvocationException
RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at UiPathCodeRunner_5fd1c3541ac447008c65339fa3541398.Run(DataTable& dt2, DataTable dt1)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object[] args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List`1 inArgs, IEnumerable`1 imps, Object[] args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.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)
Kindly help me to fix my linq query.
Thank you.