Errors with Dictionary assignment

I have a workflow that validates information in a mapping file. I want to return all of the resulting datatables in a single dictionary rather than returning 4 separate datatables.

I created the out_validated_tables variable as a Dictionary<String, Datatable> and attempt to use an assign activity:
image
image

To assign the respective datatables to a key. I have no compile time errors at this point, however when I run the code and it gets to this assign it gives this error:

image

Why doesnt this work?

Hi,

For now, can you check content of $exceptionDetails in Locals panel when the exception occurs in debug mode?
There is detailed information for the exception such as NullReferenceException etc.

Regards,

Here is the result of that log:
RemoteException wrapping System.InvalidOperationException: Can not assign ‘company_location_dt’ to ‘out_validated_tables(“CompanyLocation”)’. —> RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at Namespace_436b.DataValidation_Expressions.DataValidation_Expressions_TypedDataContext2.__Expr79Set(DataTable value)
at Namespace_436b.DataValidation_Expressions.DataValidation_Expressions_TypedDataContext2.ValueType___Expr79Set(DataTable value)
at System.Activities.XamlIntegration.CompiledLocation1.set_Value(T value) at System.Activities.Location1.ReferenceLocation.set_Value(T value)
at System.Activities.Location`1.set_ValueCore(Object value)
at System.Activities.ActivityContext.SetValueCore[T](LocationReference locationReference,
T value)
at System.Activities.ActivityContext.SetValue[T](LocationReference locationReference,
T value)
at System.Activities.Argument.Set(ActivityContext context,
Object value)
at UiPath.Core.Activities.AssignOperation.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)
— End of inner exception stack trace —
at System.Activities.Statements.Throw.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 see it has object not set to instance of an object, however I can verify that company_location_dt is set and includes data.

Hi,

Probably the dictionary is null. Did you create dictionary instance in advance as the following?

out_validated_tables =  New Dictionary(Of String,DataTable)()

image

Note: Please use Assign activity or set Default value in variable panel.

Regards,

1 Like

That was it. Good catch.

1 Like

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