Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
675
How do I get a list of EventHandlers for UltraTextEditor.ValueChanged event?
posted

Hi, There

I'm trying to debug an issue that ValueChanged event handling code not getting called, only at one specific installation on a customer site. I'm trying to generating some debugging code to make sure the event handler is properly hooked up on this installation. I'm using the following code to check for event handler:

Type tp = myTextEditor.GetType();
System.Reflection.FieldInfo[] flds = tp.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
do
{
  foreach (System.Reflection.FieldInfo fldInfo in flds)
  {
    if ((fldInfo.Name == "ValueChanged") || (fldInfo.Name == "EventValueChanged") || (fldInfo.Name == "EVENT_VALUECHANGED"))
    {
      object ob = fldInfo.GetValue(myTextEditor);
      Delegate dl = fldInfo.GetValue(myTextEditor) as Delegate;
      if (dl != null)
      {
        Delegate[] dls = dl.GetInvocationList();
        foreach (Delegate hdler in dls)
        {
          Logging.LogThis("LogEventHandler:: Handler " + hdler.Method.Name, LogType.Information);
        }
      }
      return;
    }
  }
  tp = tp.BaseType;
  flds = tp.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
} while (tp != null);

However, when I try this code on my local machine where ValueChanged event handler get called properly, I'm not getting any handler reported from dlGetInvocationList(). The line

object ob =  fldInfo.GetValue(myTextEditor);

returns an object, but I can't determine its type. However, on the following line when I tried to cast the object as Delegate, I got null. My break point in the ValueChanged event handler is getting hit so I know the event handler is linked properly. But why am I not seeing anything here? Is there anything with this code?

Thanks in advance.

Richard Zhu