private void ExecuteCommand(Expression<Func<bool>> command)
{
bool success = command.Compile().Invoke();
}
private void Test()
{
ExecuteCommand(() => _gc.ChargeCancellation(""));
}
With this code, I got a NullReferenceException.
private void ExecuteCommand(Expression<Func<bool>> command)
{
bool success = command.Compile().Invoke();
}
private void Test()
{
ExecuteCommand(() => _gc.ChargeCancellation(""));
}
With this code, I got a NullReferenceException.
Is _gc
null by any chance? Or perhaps ChargeCancellation
itself is throwing the exception? It should work fine otherwise.
Since you show no code to initialize _gc
, my guess is that is where your NullReferenceException is happening.
Either that or something inside _gc.ChargeCancellation(
) is throwing the Exception.
It might help if you included the full text of the Exception so we knew exactly where the Exception was being thrown.
Look through the stack trace or add a breakpoint at this line:
ExecuteCommand(() => _gc.ChargeCancellation(""));
Given the information you have posted there's no chance of anybody in this community really helping you beyond generic comments.