FieldInfo is ok on csarp but not on vb because of WithEvents

  • Thread starter Thread starter Nicolas
  • Start date Start date
N

Nicolas

What shuld I do on my code to make it work on both vb and csharp(ok). This
code are in a dll

It seems that withevents cause a problem on fieldinfo

private Control getObject(string ControlName)
{
//return an handle of the control
try
{
if(ControlName != FormOwner.Name)
{
BindingFlags bf = BindingFlags.IgnoreCase | BindingFlags.Instance |
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static |
BindingFlags.GetField;
Type t = FormOwner.GetType();

----- PROBLEM HERE ------
System.Reflection.FieldInfo fi = t.GetField(ControlName,bf)
;------------------------------------
object o = fi.GetValue(FormOwner);
return (Control)o;
}
else
{
return FormOwner;
}
}
catch
{
return null;
}
}



Thank for the help
 
Yes, It will be good but if an application got hundred or more control then
it become cumberstom to remove all handlers and then add them later on in
the application.
 
Back
Top