Skip to content

NullReferenceException in ActionMessage when EnableGuardDuringInvocation is enabled without guard (WPF, not MAUI) #1022

@MartinBuehlmann

Description

@MartinBuehlmann

The invocation of an ActionMessage results in a NullReferenceException when used in a WPF application if EnableGuardDuringInvocation is set to true and no guard exists.

It looks like someone tried to optimize the null check by using the ? syntax, but in fact the _context was checked against null instead of the Func CanExecute.

See ActionMessage.cs
if (EnforceGuardsDuringInvocation && _!context?.CanExecute())
{
return;
}

I laready prepared a pull request:
#1021

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions