Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[4371] Writing Plugin-Based Applications

Last post 06-03-2008 12:13 AM by Criptych. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [4371] Writing Plugin-Based Applications

    This thread is for discussions of Writing Plugin-Based Applications.

    • Post Points: 45
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 04-27-2004 11:51 AM In reply to

    • malloc
    • Not Ranked
    • Joined on 04-27-2004
    • New Member
    • Points 5

    great, but what about vb6?

    Hi.

    I've been trying to find the way of doing an application with pluggable components over vb6, but have not found any help. I read the subject of this article and was very excited but when I realized it was about .net I got frustrated. Could you please explain me how it is possible to make a plugin-based app in vb6.
    Thanx

    __________________________
    malloc
    • Post Points: 0
  • 09-30-2004 11:42 PM In reply to

    AvailablePlugin

    I can't get AvailablePlugin to work. VB.NET reports that
    "Type 'AvailablePlugin' is not defined." Has anyone else had this problem?
    • Post Points: 0
  • 06-17-2005 3:30 PM In reply to

    • Prozac
    • Not Ranked
    • Joined on 06-17-2005
    • New Member
    • Points 10

    Problem with loading assembly

    I noticed that when I used [Assembly].LoadFrom(), it kept on loading the first plugin that was initially loaded,
    to fix this; use [Assembly].LoadFile() insted.

    DotNet Framework 1.1, Visual Studio 2003, Visual Basic.NET.
    • Post Points: 0
  • 06-17-2005 3:31 PM In reply to

    • Prozac
    • Not Ranked
    • Joined on 06-17-2005
    • New Member
    • Points 10
    The complete code is available in the source code, however I'll post it for you anyway.

    Code:

       Public Structure AvailablePlugin
           Public AssemblyPath As String
           Public ClassName As String
       End Structure


    Enjoy!
    • Post Points: 0
  • 11-30-2005 1:59 AM In reply to

    adding controls to modify the host form

    Hi Tim,

    I think your article is great, i'm looking for it for months, and finally...

    I just have a question:

    If I want that a plugin add a button ont the host form, is it possible? can you help me please?

    thanks in advance,
    Ivan
    • Post Points: 10
  • 12-09-2005 5:11 PM In reply to

    • borvik
    • Not Ranked
    • Joined on 12-09-2005
    • New Member
    • Points 5

    VB2005

    Great article!

    This will come in very handy with an application I have in mind .

    Just a note about using this in VB2005 (I'm using Express edition right now, hopefully I'll upgrade):

    The CreateInstance method of the PluginServices works fine, and does return an instance of the class that can be used but only when put into an Object type.

    You don't have the full list of functions and subroutines available to you using the object.

    When using the DirectCast, to cast the instance to an variable declared as the Interface - it doesn't like that cast and throws an exception.

    To fix this do what Prozac mentiond - change the references of [Assembly].LoadFrom() to [Assembly].LoadFile() and it works fine.

    Thanks for the great article!
    • Post Points: 0
  • 10-16-2006 1:35 PM In reply to

    Re: [4371] Writing Plugin-Based Applications

    This artice was just what I was looking for - however it turned out to lead me to the conclusion that the feature I wanted wasn't achievable by .Net - at least not without some dirty coding... You code describes plugging in, but not plugging out. To my shock I realized that .Net doesn't allow unloading of assemblies!

    I needed the plug in functionality to swap and update plug-ins on a regular basis, for an ASP.Net application. However, it seems I must shut down the site completely to replace an existing plug-in with a new version...
    • Post Points: 5
  • 04-15-2007 11:20 AM In reply to

    • novy
    • Not Ranked
    • Joined on 04-15-2007
    • Poland
    • New Member
    • Points 5

    Re: [4371] Writing Plugin-Based Applications

    I rewrote your application in C# and everthing works except one thing.

    After loading  assembly and creating plugin instance I am casting plugin instance to plugin interface and I get excepion "Specified cast is not valid"

    I have no idea what is wrong.

    • Post Points: 5
  • 06-19-2007 8:23 AM In reply to

    Writing Secure Plugin-Based Applications

    I liked this article, all seven times that I read it. But I felt that it lacked a bit of security. I came across this article on msdn. It shows quite nicely how to wrap untrusted code in a sort of security blanket.
    • Post Points: 5
  • 08-22-2007 3:02 PM In reply to

    • JazzyXun
    • Not Ranked
    • Joined on 08-16-2007
    • United Kingdom
    • New Member
    • Points 10

    Re: adding controls to modify the host form

    Hi There,

    I found a very easy way to add controls to the host.

    Public Function InitializeMenu() As System.Windows.Forms.ToolStrip Implements Interfaces.IPlugin.InitializeMenu
            Dim Menu As New ToolStrip
            Dim menu1 As New ToolStripMenuItem("Plugin")
            menu1.DropDown = CreateCheckImageContextMenuStrip("Calculate")
            Menu.Items.Add(menu1)
            Menu.Dock = DockStyle.Top
            Return Menu
     End Function










    The interface should have this:    
    Function InitializeMenu() As ToolStrip



    Now you are able to add an control to the host like this:
    Me.ToolStripContainer1.TopToolStripPanel.Controls.Add(objPlugin.InitializeMenu)

    The only thing i did not figure out yet is how to handle when you click on the control.













    • Post Points: 10
  • 06-03-2008 12:13 AM In reply to

    • Criptych
    • Not Ranked
    • Joined on 06-03-2008
    • United States
    • New Member
    • Points 5

    Re: adding controls to modify the host form

    Just add event handlers to the menu items before returning from InitializeMenu, e.g.

    menu1.Click += new EventHandler (nameOfCallbackFunction);

    • Post Points: 5
Page 1 of 1 (12 items)