-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>();
}

2 Answers 2

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 .

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.