The type initializer for 'GlobalVariablesNamespace.GlobalVariables' threw an exception

Hi this is Rizwan,
I am using UiPath for excel reports automation,
I have created project with global variables and successfully ran the project for the reporting month, now I am running the same project for next month changing only the globale variable value to the new month, and it gives me the below error,
appreciate any kind help,

23.10.2+Branch.support-v23.10.Sha.a4958911688b8caaf944cdeb6d6ce4fc94195cc4

Source: Message Box

Message: The type initializer for ‘GlobalVariablesNamespace.GlobalVariables’ threw an exception.

Exception Type: System.TypeInitializationException

System.TypeInitializationException: The type initializer for ‘GlobalVariablesNamespace.GlobalVariables’ threw an exception. —> System.NullReferenceException: Object reference not set to an instance of an object. at GlobalVariablesNamespace.GlobalVariables…cctor()
— End of inner exception stack trace —
at GlobalVariablesNamespace.GlobalVariables.get_GV_FOLDER_PATH()
at Namespace_891c._000_Main_Expressions._000_Main_Expressions_TypedDataContext1_ForReadOnly.__Expr0Get()
at Namespace_891c._000_Main_Expressions._000_Main_Expressions_TypedDataContext1_ForReadOnly.ValueType___Expr0Get()
at Namespace_891c._000_Main_Expressions.InvokeExpression(Int32 expressionId, IList1 locations, ActivityContext activityContext) at System.Activities.Expressions.CompiledExpressionInvoker.InvokeExpression(ActivityContext 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, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Hi @sd_md_rizwan

The exception message indicates a ‘System.NullReferenceException’ , which suggests that an object reference within the initialization of the global variables is not set to an instance of an object.

Looks like same issue faced by many people.

Delete the variable & re-create it again in Data Manager by giving the Default value.

Ref:https://forum.uipath.com/t/global-variables-are-not-declared-after-reopening-the-file/510835

Hope this helps :slight_smile: