我认为这应该可行……但事实并非如此。我得到一个 MissingMemberException。
class Program
{
    static void Main(string[] args)
    {
        typeof(Class1).InvokeMember("Prop",
                                      System.Reflection.BindingFlags.Public |
                                      System.Reflection.BindingFlags.Instance |
                                      System.Reflection.BindingFlags.SetProperty, null, new Class1(), new object[] { TestEnum.One });
        typeof(Class1).InvokeMember("Prop",
                                      System.Reflection.BindingFlags.Public |
                                      System.Reflection.BindingFlags.Instance |
                                      System.Reflection.BindingFlags.SetProperty, null, new Class1(), new object[] { (int)1 });
    }
}
public class Class1
{
    public TestEnum Prop { get; set; }
}
public enum TestEnum : int
{
    One = 1,
    Two,
    Three
}
这似乎与其他所有 System.Reflection 方法的行为相矛盾......关于如何让 DefaultBinder 正确识别要使用的方法的任何想法?还是另一种方法?