The Sandbox Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Hosting .exe and .dll files in your own application

Back to Forum: The Sandbox
  • User profile image
    Stitch 2.0

    Ok guys,

    here is a sample of a basic plugin framework.

    The solution consists of 3 projects:

    • MainPlugInTest
    • PlugIn1
    • PlugIn2

    So, what do they do:
    PlugIn1 and PlugIn2 are two very simple demo solutions.
    PlugIn1 is a winform on which a circle is drawn.
    PlugIn2 is also a winform with a textbox and a button. PlugIn2 is compiled as a dll.

    MainPlugInTest is where the magic happens... Tongue Out

    First we have a function called DiscoverPlugins()
    It takes the plugin path (defined as a static string in the source) and gets all dll and exe files in that directory. It also creates menuitems for each plugin found.

    The other main function is LoadPlugIn(object data)
    It is fired, once the user clicks on a menuitem, under the "Plugins" menu, and takes the clicked menuitem as parameter.
    It uses the displayname of the menuitem to find the corresponding dll or exe plugin and then loads it.
    The function then iterates through all the types defined in this assembly and instantiates all forms.

    With the help of the Assembly.EntryPoint property it should be possible to find out which form to instantiate. I haven't tried it though.

    I hope, somebody might find this useful.

    Anyhow: Enjoy!

    EDIT: I have no idea how this works.... Let's see Cool

  • User profile image

    Does this functionally relate to the Composite UI application block from the patterns team?

  • User profile image
    Stitch 2.0

    lethalbyte wrote:

    Does this functionally relate to the Composite UI application block from the patterns team?

    Not really... Tongue Out

    I wrote this more than a year ago (June '04) and I just wanted to build a framework for an app I built back than. Nothing documented to use by other developers, just something I could use to add functionality...

  • User profile image
    Tom Servo

    Ideally, you'd implement a reflection pass on all executables, that loads the files in a seperate appdomain and probes them for actual plugin code, and adds all qualifying files onto a list including all sort of information that can be extracted (attributes for example). This allows you to identify plugins, decide what to load or not (via config file or whatever else), prevent unnecessary code files to be loaded into your main appdomain, and even eliminate the plugin directory.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.