リフレクションを使用してプライベートメソッドを取得するのに問題があります。BindingFlags.NonPublicおよびBindingFlags.Instanceを使用しても、機能しません。HandleClientDrivenStatePropertyChangedは、CreateRadioPropertyInstancesメソッドと同じクラスで定義されます。
class Program
{
static void Main(string[] args)
{
RadioPropertiesState state = new RadioPropertiesState();
}
}
internal class RadioPropertiesState : BaseRadioPropertiesState
{
}
internal class BaseRadioPropertiesState
{
public BaseRadioPropertiesState()
{
CreateRadioPropertyInstances();
}
private void CreateRadioPropertyInstances()
{
// get the method that is subscribed to the changed event
MethodInfo changedEventHandlerInfo = GetType().GetMethod(
"HandleClientDrivenStatePropertyChanged",
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.IgnoreCase);
}
private void HandleClientDrivenStatePropertyChanged
(object sender, EventArgs e)
{
}
}
GetMethodはnullを返します。何が問題になる可能性がありますか?
[編集されたコード]