Object reference not set to an instance of object in getText


I am using get text activity to fetch a text on ui, and enclosing that get text in try catch,
in catch i have used system.exception
and after that i am using if condition to check if msgBox.Equals(“founnd”)

In this scenario it working fine when the text is found on ui if not found then it should assign some other value in my var
but it showing nothing and through me error



RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at Namespace_78de.checkForMedicareHandling_Expressions.checkForMedicareHandling_Expressions_TypedDataContext4_ForReadOnly.__Expr4Get()
at Namespace_78de.checkForMedicareHandling_Expressions.checkForMedicareHandling_Expressions_TypedDataContext4_ForReadOnly.ValueType___Expr4Get()
at Namespace_78de.checkForMedicareHandling_Expressions.InvokeExpression(Int32 expressionId,
IList1 locations, ActivityContext activityContext) at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(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.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)

Attached ss as as well.

Just remove the if and other Try Catch make like this:
One Try Catch does it all.
Put getText in Try, Assign in Exception, and Message Box in Finally.


1 Like

if still error persists, then try to initialize the variable at start and assign empty string to it.


@Kalpesh_Chaudhari @michael.zura

Thanks guys it worked

1 Like

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