Open nitish-tt opened 5 days ago
`using Elsa.Workflows.Attributes; using Elsa.Workflows.Models; using Elsa.Workflows; using System.Text.Json; using Elsa.Extensions;
namespace ElsaServer.StorageActivity
{
[Activity("StorageActivity",
Category = "Data Storage",
Description = "Loads a serialized workflow variable's data from a file."
)]
public class GetVariableValueFromFile : CodeActivity
{
public Input
public Input<string> FilePath { get; set; } = default!;
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
var filePath = context.Get(FilePath);
var variableName = context.Get(VariableName);
var variable = context.WorkflowExecutionContext.Variables.FirstOrDefault(f => f.Name == variableName);
// this geting null
}
}
} `
Forgot to mention that I am running Elsa 3.2.0
I am running a WinForms application and loading a workflow from a JSON file exported from Elsa Studio. The workflow runs successfully, but I am unable to use any workflow variables; they always return null. Additionally, any C# or JavaScript expressions I attempt to use do not evaluate, causing a runtime error.
The call stack reveals a NullReferenceException as shown below:
`Elsa.Workflows.Middleware.Activities.ExceptionHandlingMiddleware: Warning: An exception was caught from a downstream middleware component
System.NullReferenceException: Object reference not set to an instance of an object. at Submission#4.<>d__0.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync(...)
at Elsa.CSharp.Services.CSharpEvaluator.EvaluateAsync(...)
at Elsa.CSharp.Expressions.CSharpExpressionHandler.EvaluateAsync(...)
at Elsa.Extensions.ActivityExecutionContextExtensions.EvaluateInputPropertiesAsync(...)
at Elsa.Workflows.Middleware.Activities.DefaultActivityInvokerMiddleware.InvokeAsync(...)
`
Steps to Reproduce
Expected Behavior Variables should be accessible and return valid values, and C# or JavaScript expressions should evaluate correctly during the workflow execution.
Actual Behavior Variables always return null and expressions are not evaluated, leading to a NullReferenceException in the workflow execution.
Log Output Logs show the following warning message related to the null reference error:
`Elsa.Workflows.Middleware.Activities.ExceptionHandlingMiddleware: Warning: An exception was caught from a downstream middleware component
System.NullReferenceException: Object reference not set to an instance of an object. `
Additional Context This issue only occurs when running the workflow from a JSON file exported from Elsa Studio in Winfrom Application. The same expressions and variable manipulations work correctly when run on elsa server.
https://v3.elsaworkflows.io/docs/guides/loading-workflows-from-json this is Code i m using in my Winfrom Aplication.