I can’t figure it out why I’m getting exception about this line:
public void DoIt(object sender, MyEventArgs e) {
//... other stuff
Type type = sender.GetType();
if (type.GetMethod(e.ActionName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) == null)
throw new NotSupportedException("Method: " + e.ActionName + " not implemented");
type.InvokeMember(e.ActionName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null, sender, e.Parameters.ToArray());
}
I’m still getting error about method is not found, but I’m sure it is because condition in if-statement before invoking is false.
Actually, it’s a security feature. I’ve encountered this previously in Silverlight – you simply cannot reflect on private class members on that platform. With Windows Phone being quite similar to Silverlight, I am pretty sure same restrictions apply there as well.