Architecture advice

J

John

Hi

I am designing a brand new vb.net application. My aim is to have the main
app as a shell only and all real functionality is provided by plug-in
modules. Modules are to be loaded at runtime depending on which modules are
present. Modules also need to communicate to the main app to display such
and such toolbar and menu options. Main app needs to pass on toolbar & menu
selection to the current module. Some modules have UI elements (form). Its
ideal to have the modules as executables so they can be tested while under
development on their own too. What sort of infrastructure I am looking at?
Ideally I would like to do this in vs 2005 beta2.

Thanks

Regards
 
N

Nick Malik [Microsoft]

Ultimately, this isn't all that difficult. Your main app will need to
define the interface that all of your plug ins will use. The main app will
look to either a config file, or perhaps a local directory or registry entry
where mutiple config files can be referenced. That will provide the app
with the name of the plug-in that you need to call.

I'd suggest setting it up so that the main app opens, looks for a list of
plug-ins (registry perhaps), and then calls each one, passing in an object
that contains a representation of the menu structure. The plug in will add
items to the object representing changes to the menu structure that each
plug-in wants to see.

You could use delegates, or more simply, you could use a command pattern,
whereby the menu item would produce a "command" event that the main app
would send to the plug-in that registered the menu entry.

Your main app should probably create an abstract base class for any windows
that the plug-ins will need to open. That way, the plug in apps will
inherit from that base class instead of inheriting directly from
windows.forms.form. That way, you can have some control over the list of
windows that are open, and your main app will have a mechanism for doing
things like sending a "close" event to all windows when the system shuts
down or the user indicates "Exit" from the File menu.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
J

John

Hi Nick

Many thanks for the detaild reply.

What sort of mechanism should the main app use to load the plug-in modules?

Thanks again.

Regards
 
N

Nick Malik [Microsoft]

The string in the registry would contain the name of the plug in, and the
main app would use reflection to load it up. Look up LoadLibrary

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top