Question Regarding Plugin Architecture

Discussion in 'ASP .Net' started by Joseph Ferris, Nov 27, 2005.

  1. I am working on a Web Application that can dynamically load
    UserControls, a la a plugin style system. When I create any new
    controls within the project, all is fine.

    What my question is, would be how might I be able to allow someone to
    create a plugin that would not require that I rebuild the application -
    or is it even possible? Right now, this is what I have:

    A BasePage class that inherits from System.Web.UI.Page that is used to
    extend the Page object for extended rendering functionality.

    A BaseControl class that inherits from System.Web.UI.UserControl that
    is used to extend the UserControl object for specific rendering
    capabilities that are used by all plugins.

    I have a page that inherits from BasePage. To it, I've added a
    PlaceHolder control. Then on Page_Load, I simply use LoadControl to
    load the specific control and add it to the PlaceHolder. My ultimate
    goal would be to build up a repository of these objects in a database
    so that I could configure certain controls to be used in certain
    situations. Basically, it is a CMS-type application.

    Like I mentioned, as long as the control exists in the main project,
    all is well. But assume that a third party wants to develop a plugin.
    I don't want to give access to the code to that person, for obvious

    Are my options limited to adding the DLL from the plugin to the /bin
    folder of the main application? After I do that, how do I get the
    application to recongize the DLL? If I put them in a subfolder
    structure to keep them organized, does this impact anything in regards
    to the ability to load the control?

    Thank you, in advance, for any input.

    Joseph Ferris, Nov 27, 2005
    1. Advertisements

  2. I have made some progress. What I am doing now, instead of
    LoadControl, is I am creating a reference to the Assembly by using
    Assembly.LoadFrom(). I then cast it to the correct control type and
    assign it to the control collection of a placeholder on the calling
    page. This is what I have in my Page_Load on the ASPX page:

    Dim MyPlaceHolder As PlaceHolder =
    CType(Me.FindControl("TemplateHolder"), PlaceHolder)

    If Not MyPlaceHolder Is Nothing Then

    Dim DynamicASM As [Assembly]
    DynamicASM =

    Dim ControlInstance As MyLib.Page.Controls.Template =



    End If

    The TestOutput() method is defined in the base control instance, and
    outputs "Base" to the screen when called, if it is not overriden. I
    override it in the derived instance to display "Derived". When I run
    the above code, it displays "Derived". But now, my new problem...

    Any content in the derived control is not displayed. For example, I
    added a table in the designer and recompiled. The instance I create
    from the assembly is displaying "Derived", so it is creating it. The
    events of the derived control are also being hit correctly, if I add
    breakpoints in the debugger. I just can't get the table to show. I am
    assuming that something is happening in LoadControl that this approach
    does not do.

    Does anyone have any idea as to might what be going on, or have a
    better approach to this? I am feeling a little lost at the moment.


    Joseph Ferris, Nov 27, 2005
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron Queenan

    Plugin architecture

    Aaron Queenan, Jun 3, 2004, in forum: ASP .Net
    Paul Wardle
    Jul 6, 2004
  2. PilotYid
    Andrew Thompson
    Oct 31, 2005
  3. Marcin Cenkier
    Marcin Cenkier
    Apr 12, 2006
  4. Jimmy
    Mar 15, 2007
  5. Replies:

Share This Page