-1

I want to implement an entity class in my Azure Durable Function. This should store a list of codes. Unfortunately, I get the following error when executing the Set method:

System.NullReferenceException: 'Object reference not set to an instance of an object.'.

Here is the code:

[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class OrchestrationStatus
{
    [JsonProperty("orchestrationStatus")]
    public List<string> orchestrationStatus { get; set; } = new List<string>();

    public Task Set(string code) 
    {
        this.orchestrationStatus.Add(code);

        return Task.CompletedTask;
    }

    public Task<List<string>> Get() 
    {
        return Task.FromResult(this.orchestrationStatus);
    }

    [FunctionName(nameof(OrchestrationStatus))]
    public static Task Run([EntityTrigger] IDurableEntityContext ctx)
        => ctx.DispatchAsync<OrchestrationStatus>();
}
Jonas
  • 25
  • 5

2 Answers2

0

If you are trying to access a member of a class instance using a null reference then you will get a System.NullReferenceException : Object reference not set to an instance of an object.

Please check the below links for more information:

.Object reference not set to an instance of an object | SO THREAD

.What does “Object reference not set to an instance of an object” mean| SO THREAD .

.Durable Entities in .NET .& To create Durable function |MS DOC .

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15
0

I was able to solve the problem by removing breakpoints from the entity class. Apparently, there is a bug with the debugger!

Jonas
  • 25
  • 5