Dynamically load child DLLs?

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

Hi,

I'm looking at making a piece of software which will have a central
executable file, and a list of DLLs (kind of like Office "add-ins")
that will provide different functionalities - the idea being I can
write new modules as and when they're needed, and distribute them to
customers as necessary.

Could anyone provide any advice as to the best way to go about this? I
was thinking a list of "installed" modules could be stored in the
registry. I'm then hoping that I could do something along the lines of
loop through the list, and create an array of "modules" by referring to
different objects in different DLLs.

Is it possible to load a DLL by name, and create an instance of an
object by name (i.e. dynamically, at runtime - not at designtime)? If
so, how do I do this? I'm envisaging that all modules will have
objects implementing the same interface.

Thank you in advance for your help!

Stuart Jones


To e-mail me, replace the part of my e-mail after the @ with
university-college.oxon.org
 
Stu said:
I'm looking at making a piece of software which will have a central
executable file, and a list of DLLs (kind of like Office "add-ins")
that will provide different functionalities - the idea being I can
write new modules as and when they're needed, and distribute them to
customers as necessary.

Could anyone provide any advice as to the best way to go about this? I
was thinking a list of "installed" modules could be stored in the
registry. I'm then hoping that I could do something along the lines of
loop through the list, and create an array of "modules" by referring to
different objects in different DLLs.

Is it possible to load a DLL by name, and create an instance of an
object by name (i.e. dynamically, at runtime - not at designtime)? If
so, how do I do this? I'm envisaging that all modules will have
objects implementing the same interface.

Thank you in advance for your help!

Have a look at http://www.pobox.com/~skeet/csharp/plugin.html

It's mostly for people who are already having problems, but it gives
you a little bit of framework to see what you need to do.

(You have my sympathy by the way - but I suppose someone has to go to
Oxford ;)
 
Eric said:
Have a look at articles I wrote in September 2003 and August 2005 from
http://emoreau.s2i.com/


Thank you both for your help - it's exactly the sort of stuff I had in
mind :-)

Have a peaceful Christmas and a prosperous New Year!

(And as for Oxford - I just never liked Cambridge's nasty duck-egg blue
from an early age...)
 
Stu said:
Thank you both for your help - it's exactly the sort of stuff I had in
mind :-)

My pleasure. Do ask if anything else goes wrong - in my experience,
it's rare to get this kind of thing working first time :)
Have a peaceful Christmas and a prosperous New Year!
Likewise.

(And as for Oxford - I just never liked Cambridge's nasty duck-egg blue
from an early age...)

Yeah. I think we let you have the nicer colour to make up for
everything else.
 
Back
Top