Dynamically load a form

  • Thread starter Thread starter kendu
  • Start date Start date
K

kendu

Is it possible to dynamically load a form from file? This form is just
a .vb file and has not been added to the project during design time.

Ken
 
Is it possible to dynamically load a form from file? This form is just
a .vb file and has not been added to the project during design time.

Yes, you can use reflection (System.Reflection namespace) to dynamically
load classes - either from an assembly (DLL) or from source code (from
source code you'll need to dynamically compile the file too).
 
kendu said:
Is it possible to dynamically load a form from file? This form is just
a .vb file and has not been added to the project during design time.

This is not a good way to do what I think you're trying to achive (addin
sort of functionality). The form should be compiled into a dll and then the
dll should be loaded.
 
Spam said:
Yes, you can use reflection (System.Reflection namespace) to dynamically
load classes - either from an assembly (DLL) or from source code (from
source code you'll need to dynamically compile the file too).

The idea is to generate forms at run-time then view them. Thanks, SC.
Wonder if there is any good code example? I know, it's getting kind of
gritty :-)
 
kend9u said:
The idea is to generate forms at run-time then view them. Thanks, SC.
Wonder if there is any good code example? I know, it's getting kind of
gritty :-)

Why not generate them using native code? Why write it to a file?
 
Michael said:
Why not generate them using native code? Why write it to a file?

We're going to re-use the generated forms by adding them to other
projects, Michael. Got the source code for the forms generated and
written to disk files already. The next step would be compiling and
displaying these files at run-time. "Quick and dirty" ways to
accomplish the tasks are much appreciated. Any wrapper to handle it
out there?

Ken
 
This is not a good way to do what I think you're trying to achive
(addin sort of functionality). The form should be compiled into a dll
and then the dll should be loaded.

Yes, I agree, that is the better way.

Another possiblity is to use the VS.NET designer component to serialize a
generated form. The form can then be easily reloaded or transferred to
another app.
 
Back
Top