Hello all,
I mailed our common hero and fellow newsgroupian Jon Skeet a question
regarding his article on plugins at
http://www.yoda.arachsys.com/csharp/plugin.html, and he suggested that I
should post here. I was afraid to spam the group further with my silly
questions, but I agree with his sentiment that this might benefit
others, so here we are.
My question regards the proper way to build the plugin projects. My host
application is a typical winforms application; I want to create an
interface that I can then code plugins towards for all the usual
benefits. That's fine. I figure I will make some hooks for the plugins
to add custom menus to the program at certain points, add new windows,
present their config interface etc.
The way I figure it, I need two interfaces; One for the plugin itself.
It needs to implement some initialization method, a deinit-method, a
showconfig-method and some other stuff. The host interface, on the other
hand, would present the plugin with common data and events to subscribe
to. Hopefully this is relatively simple.
My question (at long last) is how I should practically approach this. Is
the simplest thing to make several C# projects like these?
1) Host Application
2) Interface only class library
3) Plugin A
4) Plugin B
Or is that a braindead way of doing it?
Also, lets say I have a directory structure like this;
$PROGRAMFILES\MyApp\
MyApp.exe
somedll.dll
plugininterface.dll
Plugins\
plugina.dll
pluginb.dll
Will I also need to stick the plugininterface.dll in the Plugins folder?
Or will I need to register the dll somehow?
As you can see, my question isn't so much about the actual coding of the
plugins/interface/host application (I've got plenty of information from
Jon's article and google on that), it's about organizing the projects
and/or solutions.
It is easy to find plenty of information on how Interfaces work in C#,
why they are the Correct Way etc., but it's been hard to find proper
information on how to organize this neatly into projects. In the future,
maybe an external developer wants to write a plugin for my application -
in that case, I don't really want to give him access to any source code
or logic beyond the plugin/host interfaces, so a nice separation of
these things would be awesome.
I should also mention that I am still using Visual Studio 2003 and .net 1.1.
If anyone could shed any light on this, I would be most grateful.
Thank you very much for your help in advance!
Best regards,
Rune Jacobsen