IF Object Reference not set to an instance of an object



The error comes when the variable you are using is null or is nothing…please check the same


Hi @jokakeekian

This type of error occurs when the arguments was not correctly passed between the workflows, so check the arguments passing was correctly assigned or not.

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.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment,
ActivityInstance activityInstance,
ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment,
ActivityInstance targetActivityInstance,
ActivityExecutor executor,
Object argumentValueOverride,
Location resultLocation,
Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument,
Int32 nextArgumentIndex,
ActivityExecutor executor,
IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides,
Location resultLocation,
Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)

“Name”: “If”,
“Id”: “1.152”,
“InstanceId”: “10”,
“TypeName”: “System.Activities.Statements.If”

So, i am using a messagebox. Everything works fine, but if I click the X button or exit button on the top right hand corner, this error occurs…

This is the IF code i am using

System.Text.RegularExpressions.Regex.IsMatch(ID.ToString, "^(0[1-9]|[1-9][0-9]{1}|[1-2][0-9]{2}|3[0-2][0-9]?|330|331)$")*

Which only accepts answers from 1 - 331

No alphabets allowed too, so it’s

System.Text.RegularExpressions.Regex.IsMatch(ID.ToString, “[1]+$”)

for this. It will continue looping until the user enters the correct number

  1. ↩︎

1 Like


In this I believe yout id.ToString is empty…please check


to be honest, what do you mean by ID to string tho, Im a beginner at this



In which ever activity you are getting this error …please check the values of the variable sin them…

For that run the bot in debug mode…then when bot errors out…it pauses at some x activity…now dont stop and open the locals panel and check the variable values…one of the variable used in the activity would be null…which is causing the error…please check where the value is getting null

Hope this helps


whether if I have input no values or input something in the dialog box and immediately exits, the error appears. This assumes I have never pressed ok or enter. Can the same logic be applied.


Without entering any value if you click enter then it might be null so you can check using condition to see if data is present and then perform next steps

IsNothing(ID) orElse String.IsNullOrEmpty(ID.ToString)


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