That's about it for the PluginServices.vb
file. The rest of the application is pretty simple. In the Sub Main, we call the FindPlugins method and populate a list on the form. The user can select a plugin from this list, and has the opportunity to enter two numbers and run the plugin to see what it returns.
One more thing is needed however, and that is to create the class in the host application which implements the IHost interface, and provides the plugins with a way of calling methods in the host application. For the purposes of this sample, the method will simply display a message box.
I won't go in to everything else in the host application, hopefully the code will explain itself. It's worth noting, however, that while in this sample we create an instance of a plugin each time we want to perform a calculation, usually the lifetime of a plugin object would be much longer.
One more plugin
We will just write one more plugin, this time to multiply the two numbers. This one will also use the host interface to show a message box during calculation. The code is in the "Plugin 2" folder. That's about it. I've attached all the code that goes with this tutorial, feel free to use the PluginServices.vb
file in your own applications. It shouldn't require any modification.
Comments