Main Sequence: Object Reference not set to an instance of an object

I am getting a “object reference not set to an instance of an object” error in UiPath in the Main Sequence.

What do you suggest could be the issue?

This is the full error:

RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure ,
ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance,
Activity1 expressionActivity) at System.Activities.Variable1.PopulateDefault(ActivityExecutor executor,
ActivityInstance parentInstance,
Location location)
at System.Activities.ActivityInstance.ResolveVariable(Variable variable,
ActivityExecutor executor)
at System.Activities.ActivityInstance.ResolveVariables(ActivityExecutor executor)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)

Debugging and trace / inspect the variables:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi @benjiherb

Object reference not set to an instance of an object error will throw
→ In your error it is NullReferenceException, if any variable haven’t initialized with the proper values.
→ when the variables or argument are not passed properly.
→ Variable which is not in the current scope.
→ If any of the mandatory fields are not filled in any activity.

Check the above scenarios in the activity where you are getting error.
It’s recommended to debug the code and you can know which activity throwing this error.

Hope it helps!!

I am running it in debug. There are only 2 arguments, which are not null, and no variables.

I understand this. However, there are no variables in the locals panel.

Have you debug the code, in which activity the error was throwing… @benjiherb

It’s the main sequence. As soon as the bot tries to execute the sequence, the error is thrown.
System.Activities.Statements.Sequence

Check your variable defaults, you might have one variable that uses another variable in its default - and you can’t do that.

There are no variables when the bot first executes. When the bot starts, there are only has 2 arguments, and they are populated normally. I’ve also tried deleting the arguments as a test, but the error persists.

You have no variables in your automation? When it first tries to run the very first thing it does is process the variables. I’m talking about the variable definitions in the variables pane.

1 Like

Thank you so much! This was the problem. I had a default value in one variable which was another variable that was not initialized.

1 Like

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