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
sorry, forgot to mention the version of my Infragistics. We are using 11.2.20112.1010.
Thanks.
Hello,
You can get a list of event handlers using the following code:
Type type = this.ultraTextEditor1.GetType().BaseType;EventHandlerList events = (EventHandlerList)type.GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.ultraTextEditor1, null);object key = type.GetField("EVENT_VALUECHANGED", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);Delegate handlers = events[key]; foreach (Delegate handler in handlers.GetInvocationList()){ MessageBox.Show(string.Format("EventHandler : {0}", handler.Method.Name));}
Type type = this.ultraTextEditor1.GetType().BaseType;EventHandlerList events = (EventHandlerList)type.GetProperty("Events", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.ultraTextEditor1, null);object key = type.GetField("EVENT_VALUECHANGED", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);Delegate handlers = events[key];
foreach (Delegate handler in handlers.GetInvocationList()){ MessageBox.Show(string.Format("EventHandler : {0}", handler.Method.Name));}
Please let me know if there is anything further I can do to help.