blazej blazej

blazej blazej

  • NA
  • 1
  • 4.1k

How to get controls of the form from an assembly using Reflection?

May 12 2011 5:16 AM
I am trying to retrieve all control names of the form from compiled assembly. 
 
I can get the list of all forms:
Assembly asm = Assembly.LoadFrom(_assemblyPath); // Get the list of types defined in the assembly and derived from System.Windows.Forms.Form var lForms = asm.GetTypes().Where(x => x.IsSubclassOf(typeof(Form))).ToList();

But then I have a problem when I am trying to instantiate the types (as I need to retrieve the controls of the form).
I cannot use the:

Form o = Activator.CreateInstance(form, true) as Form;

as some forms have no default constructors defined.

Is there any other way to retrieve the data I need?

Regards


Answers (1)