Error Invoke Code

I’m trying to execute a file through invoke code, where the script receives the name of the file and executes it after downloading.

But this error appeared:

Invoke Code: Exception has been thrown by the target of an invocation.

Can you write the exception details?

Hello Gokul,

I’m new to RPA, I have no idea what exception I might have configured, I scoured the forum and they said if I configured the output or input argument incorrectly, this error appears.

But I did exactly the same as a video I’m studying and in the video it worked and this error came back on mine

Hello,
You can see the error details in debug mode here.
Locals → Exception → $exceptionDetails

Look what appeared

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.InvalidOperationException: Cannot start process because a file name has not been provided.
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at UiPathCodeRunner_93b085851a3146539ab193d433eb91bd.Run(String in_Arquivo)
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target,
Span1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) 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 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object[] args) at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 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)

I think, you use like a Process.start(“path”) code. Maybe you do not provide path or correct format.
If you share the code we can find an easier solution.

I had misdirected the argument, corrected it and executed it, but it resulted in another error.

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.ComponentModel.Win32Exception: An error occurred trying to start process ‘C:\Users\paulo.campagnini\Documents\UiPath\RPA - Cursos\Robo_Mailling\Recebidos\ID001.png’ with working directory ‘C:\Users\paulo.campagnini\Documents\UiPath\RPA - Cursos\Robo_Mailling’. The specified executable is not a valid application for this OS platform.

It’s probably like you said, it must be a directory error.
What’s the best way to share the code with you?

Hi @pdcampagnini ,

We would need to Handle the Exceptions happening inside the Invoke Code Activity with a Try Catch Block as mentioned in the post below :

If the Code Snippet is short, you could share it here as an Image or inside the Preformatted Text (</>). So we can have a proper visibility of the code along with it’s format.

If the Snippet is longer than usual, you could share it via a text file.

Do let us know about the code snippet and if you were able to implement the Try Catch block.

I couldn’t put the try catch to pass the log, but I made a video, you need to find which part?

Does the exception log help?

Hi, here three different way for start a file.
Main.xaml (6.2 KB)

Good morning, I apologize for the delay in the feedback.

From the file you gave me, it would run the file that is in the path I put right? What if in that path it has several files stored?

The idea is for him to download and open the file he downloaded in the folder

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