HOW TO: Use user defined DLLs as plugins

  • Thread starter Thread starter M. Angelo
  • Start date Start date
M

M. Angelo

Situation:
An EXE scans the path for DLLs and uses all DLLs and only the
existing DLLs
All DLLs provides the same functions while doing different processing
Program restart is NOT desired

Question:
How to declare the DLLs functions for a end user selected DLL?
 
You have to use the System.Reflection namespace. Look into using
interfaces, I've developed 4 different plugin frameworks, each has their own
purpose.
 
that made no sense...

You should use Interfaces when developing plugin frameworks, so you dont
have any misplaced DLL's in your search directory. Reflection allows you
get info about the dll you are trying to dynamically load.
 
I couldn't ever get the Interfaces to work right, so I went with ClassByName
approach. The only problem with plugins under .NET, and I will never tire
of saying this, is the damned GarbageCollector! You can't "unload" the
DLL's untill the GC either decides you are actually done with them, or you
do a GC.Collect and forcec it to, which can really hinder perfomance.
Anyhew, a google or dogpile search will return thousands of pages on how to
do plugins. I've heard the Interfaces is the way to go, so go with that.
just cause I couldn't get it to work for my situation, doesn't mean that
it's not perfect for you. Food for thought.

Sueffel
 
You know, I understand what you mean by that. That was one of the
challenges I ran across when doing my first plugin framework, it worked
fantastic if I had like 2 to 3 small plugins but as more were added it just
became slower and slower.

Now in my framework I wanted to get menu's,statusbars, etc... stuff the was
required to be persisted. Not a problem by keeping a reference to it. So,
I just developed numerous interfaces and left it up to good design by the
user. The goal, was that classes that needed to be run were instantiated
dynamically when needed, not load them all at the beginning like a lot of
frameworks do (one bad entry point can be the difference between a few megs
and 40 megs. =)

So I understand where your going with diffuculty with interfaces, but just a
little bit of work and you'll get it there. They really are quite powerful.

another useless rant...

-CJ
 
And thence such a cry didst arrise from the gathered masses. "Show unto us
the code which came from thy great swollen mellon of a brain, that we may
copy it, and claim it as our own, and use it, and gain royalties from it,
and have our users think that we wrote this magnificent code, all the while
knowing in our hearts that it is yours, and you wrote it, and it came from
thine great and swollen mellon of a brain."

And thence CJ Taylor gave us the code by which we might all implement his
great and magnificent scheme.


......
 
Back
Top