Hi all,

I have strange problem with .NET Reflection. The basic scenario follows:
Using reflection I create the object of the type in the my own assembly.
Instance is created fine. Then use reflection to get info about type fields.
I want to use the field of the object just created:

       object field = fieldInfo.GetValue(form);
       switch (fieldInfo.FieldType.FullName)
       {
 case "System.Windows.Forms.TextBox":
  txtBox = (TextBox)field;
              break;
        default:
       break;
       }
The cast statement txtBox = (TextBox)field; throws the InvalidCastException.
What I'm doing wrong ? Is casting not allowed on reflected types?

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to