UserControl, GUI inside the application on runing time, PlugIn problem

S

Sandra Baum

Hello,

I search for a good example.

My idea:
UserControl1 -- DLL1 -- with the red textbox
Textbox1 --- result = Textbox1 red
UserControl2 -- DLL2 -- with the blue textbox
Textbox1 --- result = Textbox1 blue
UserControl3 -- DLL3 -- need an additional textbox, however
Textbox1 (white) + Textbox2 (white) --- result = Textbox1 +
Textbox2

Application -- EXE

UserControlXY -- Interface/Contract -- Application/Exe

In the folder Bin\Release looking for available DLL's
DLL's - If we find more as one, we show also the versions in a
listbox

The user choose one of the Dll , the application is start up

Advantage
New UserInterface, no changes in the EXE, only chnage the DLL

How can I do that?
IPlugin _plugin = (IPlugin) ....??????

Interface is similar the result.

result = textbox1 red
result = textbox1 blue
result = textbox1 white + textbox2 white

I use VS2005, C#

with best Sandra
 
S

Stanimir Stoyanov

Hello Sandra,

Writing a plugin interface in C# is relative easy. Of course, you first have
to design it -- choose what the base functionality will be (it will be
common for all plugins). For example, your IPlugin interface must always
have a way of exposing the appropriate UserControl or a whole form to show.
You might also add a distinctive name and version as properties.

IPlugin has to be defined in a 'middle-man' assembly so that it is
referenced by both plugins, and your application. It will act as a link
between the two.

The loading part:
-- You can an array of the existing .DLL files using the System.IO.Directory
class
-- Each assembly that you have found can be loaded into the memory using
Reflection (System.Reflection.Assembly.LoadFile(...))
-- Walk through each assembly's class and check if the type implements your
IPlugin interface. If so, keep this class in a list of the eligible plugins.

You can then present the user with the various plugin options and create the
appropriate class. See the System.Activator.CreateInstance(...) method for
more information on instantiating types dynamically.

Divelements have a sample plugin architecture at
http://www.divil.co.uk/net/articles/plugins/plugins.asp. It is VB.NET-only
though.

Hope this helps,
 
S

Sandra Baum

Hello together,

have everbody a simple example with usercontrol in C#.

Thanks a lot and have a nice start in the new week.

with best Sandra
 
S

Sandra Baum

Hello together,

that is absolutely not simple.
I hope, I doesn't fall on them annoys, but I need an example.
I think that, anybody have must done it.
It would be nice, if I got an answer again.
Have a nice week.

Regards Sandra
 

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