Dynamically load a class out of a DLL and create an instance of it

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys 'n' girls,
I would like to know if there is an easy way to load a class out of dll at
runtime and create an instance of it. The class which should be loaded has a
base class which is known to the "loader" and all classes which should be
loaded implement a default constructor.

Is there any simple way? I read something about the System.Activator, but I
didn't really understand it and don't even know if it is the correct class to
handle such a thing.

greetings

Florian
 
Hi,

It goes more or less like this:

Assembly ass = Assembly.Load( path );
BaseClass ins = (BaseClass) ass.CreateInstance( .. check the correct
overload );


cheers,
 
Back
Top