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

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
 
N

Nicolas

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top