samedi 14 septembre 2019

Delegate.CreateDelegate - method arguments are incompatible

Given aMethodInfo for the following method

public class MyEffects
{
  public Task Test(object action, IDispatcher dispatcher)
  {
    return Task.CompletedTask;
  }
}

Why does the following CreateDelegate code throw System.ArgumentException: method arguments are incompatible?

Delegate.CreateDelegate(
    type: typeof(Func<object, IDispatcher, Task>),
    method: discoveredEffect.MethodInfo);

As does this

Delegate.CreateDelegate(
    type: typeof(Func<object, object, IDispatcher, Task>),
    method: discoveredEffect.MethodInfo);





Aucun commentaire:

Enregistrer un commentaire