Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Create An "add-in-able" Application

Create An "add-in-able" Application

Scheduled Pinned Locked Moved C#
comtutorial
11 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MStanbrook
    wrote on last edited by
    #1

    I've got an application to which I'm looking to add some new functionality to. I'd LOVE to be able to offer these new functional components as "add-in" modules (similar to the add-ins in VisualStudio). Does anyone have any advice or a suggested place to start looking for some resources on how to tackle this sort of "modular @ runtime" type of thing. I've got NO idea on where to begin, and any poke in the right direction would be fantastic. TIA. Mike Stanbrook mstanbrook@yahoo.com

    D E 2 Replies Last reply
    0
    • M MStanbrook

      I've got an application to which I'm looking to add some new functionality to. I'd LOVE to be able to offer these new functional components as "add-in" modules (similar to the add-ins in VisualStudio). Does anyone have any advice or a suggested place to start looking for some resources on how to tackle this sort of "modular @ runtime" type of thing. I've got NO idea on where to begin, and any poke in the right direction would be fantastic. TIA. Mike Stanbrook mstanbrook@yahoo.com

      D Offline
      D Offline
      David Williams
      wrote on last edited by
      #2

      How tightly coupled do you want the add-ins? Photoshop, I believe, uses a type of plug-in where, if a function (filter, in this case) in the right folder on startup, it is made available to the app. But I don't know what kind of internal interface it uses.

      M 1 Reply Last reply
      0
      • D David Williams

        How tightly coupled do you want the add-ins? Photoshop, I believe, uses a type of plug-in where, if a function (filter, in this case) in the right folder on startup, it is made available to the app. But I don't know what kind of internal interface it uses.

        M Offline
        M Offline
        MStanbrook
        wrote on last edited by
        #3

        Good question.:) What I was "visualizing" was this: Our application has an MSOutlook-style bar, with an icon for each of the current (4) modules that are included in the application. Ultimate Goal: Upon deployment of an additional "module" (which will preferably be just copying some new dll's into the bin dir) and some potential "configuration" settings updates, the icons representing the new "modules" will appear in the OUtlook toolbar, and call functionality contained within the new dlls that were deployed. Clear as mud right? Mike Stanbrook mstanbrook@yahoo.com

        D S 2 Replies Last reply
        0
        • M MStanbrook

          Good question.:) What I was "visualizing" was this: Our application has an MSOutlook-style bar, with an icon for each of the current (4) modules that are included in the application. Ultimate Goal: Upon deployment of an additional "module" (which will preferably be just copying some new dll's into the bin dir) and some potential "configuration" settings updates, the icons representing the new "modules" will appear in the OUtlook toolbar, and call functionality contained within the new dlls that were deployed. Clear as mud right? Mike Stanbrook mstanbrook@yahoo.com

          D Offline
          D Offline
          David Stone
          wrote on last edited by
          #4

          No in fact. That's quite clear. You are going to want to look into the System.Reflection namespace. That's where you can load an assembly into memory dynamically. As long as all your "modules" implement a common public interface, then you can just iterate through all the files in the bin directory and then load them using reflection. I hope that helps. Inside C# has a really good chapter on reflection and is my all around reference manual for C#. I would highly recommend getting that and working through the examples. Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

          E 1 Reply Last reply
          0
          • D David Stone

            No in fact. That's quite clear. You are going to want to look into the System.Reflection namespace. That's where you can load an assembly into memory dynamically. As long as all your "modules" implement a common public interface, then you can just iterate through all the files in the bin directory and then load them using reflection. I hope that helps. Inside C# has a really good chapter on reflection and is my all around reference manual for C#. I would highly recommend getting that and working through the examples. Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

            E Offline
            E Offline
            ez2
            wrote on last edited by
            #5

            This article may be of some assistance. Please not the URL wrap http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp06102002.asp

            D 1 Reply Last reply
            0
            • M MStanbrook

              Good question.:) What I was "visualizing" was this: Our application has an MSOutlook-style bar, with an icon for each of the current (4) modules that are included in the application. Ultimate Goal: Upon deployment of an additional "module" (which will preferably be just copying some new dll's into the bin dir) and some potential "configuration" settings updates, the icons representing the new "modules" will appear in the OUtlook toolbar, and call functionality contained within the new dlls that were deployed. Clear as mud right? Mike Stanbrook mstanbrook@yahoo.com

              S Offline
              S Offline
              Stephane Rodriguez
              wrote on last edited by
              #6

              A simple .config file would probably do as great. I would keep Reflection for features really requiring compiling while running, which is way beyond the static plugins you pictured.


              sometimes it helps to look at the IL generated code a MS guy on develop.com "answering" .NET issues

              M 1 Reply Last reply
              0
              • M MStanbrook

                I've got an application to which I'm looking to add some new functionality to. I'd LOVE to be able to offer these new functional components as "add-in" modules (similar to the add-ins in VisualStudio). Does anyone have any advice or a suggested place to start looking for some resources on how to tackle this sort of "modular @ runtime" type of thing. I've got NO idea on where to begin, and any poke in the right direction would be fantastic. TIA. Mike Stanbrook mstanbrook@yahoo.com

                E Offline
                E Offline
                Eric Gunnerson msft
                wrote on last edited by
                #7

                How difficult this is depends upon what your requirements are. If you want to just load add-ins at runtime, it's quite simple. 1) Define the interface you want an add-in to implement, and compile it to a .dll 2) Create a directory for add-ins off of the directory where the .exe lives 3) In the main exe, use Assembly.Load() to load in the assembly4) 4) Use reflection to find the types in it that implement your assembly 5) Use activator.CreateInstance() to create the instance 6) Cast it to your interface, and then go to town. If you want to be able to update them on the fly, that gets more complicated. Look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp for more information.

                M 1 Reply Last reply
                0
                • E ez2

                  This article may be of some assistance. Please not the URL wrap http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp06102002.asp

                  D Offline
                  D Offline
                  David Stone
                  wrote on last edited by
                  #8

                  I'm sorry sir. But you've violated CP ordinance #591634: Failure to In-Linkerate a URL. This time, we'll do it for you and let you off with a warning. But next time, you better remember to do so...;-P http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp06102002.asp [^] Norm Almond: I seen some GUI's in my life but WTF is this mess ;-) Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough:) Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children:laugh: Leppie:My sister is 25:eek: -Norm on the MailMagic GUI

                  1 Reply Last reply
                  0
                  • E Eric Gunnerson msft

                    How difficult this is depends upon what your requirements are. If you want to just load add-ins at runtime, it's quite simple. 1) Define the interface you want an add-in to implement, and compile it to a .dll 2) Create a directory for add-ins off of the directory where the .exe lives 3) In the main exe, use Assembly.Load() to load in the assembly4) 4) Use reflection to find the types in it that implement your assembly 5) Use activator.CreateInstance() to create the instance 6) Cast it to your interface, and then go to town. If you want to be able to update them on the fly, that gets more complicated. Look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp for more information.

                    M Offline
                    M Offline
                    MStanbrook
                    wrote on last edited by
                    #9

                    Eric Gunnerson (msft) wrote: _If you want to be able to update them on the fly, that gets more complicated. Look at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp_ Great article. It's a bit out of my realm for now, but looks like some interesting ideas to keep in mind while getting me feet wet! Thanks. Mike Stanbrook mstanbrook@yahoo.com

                    1 Reply Last reply
                    0
                    • S Stephane Rodriguez

                      A simple .config file would probably do as great. I would keep Reflection for features really requiring compiling while running, which is way beyond the static plugins you pictured.


                      sometimes it helps to look at the IL generated code a MS guy on develop.com "answering" .NET issues

                      M Offline
                      M Offline
                      MStanbrook
                      wrote on last edited by
                      #10

                      Interesting idea. Do you have a suggestion on how to handle separate GUI components for each of the plugins? Mike Stanbrook mstanbrook@yahoo.com

                      L 1 Reply Last reply
                      0
                      • M MStanbrook

                        Interesting idea. Do you have a suggestion on how to handle separate GUI components for each of the plugins? Mike Stanbrook mstanbrook@yahoo.com

                        L Offline
                        L Offline
                        leppie
                        wrote on last edited by
                        #11

                        HI MStanbrook Have a look at my IRC client I wrote a while back. http://myrc.sourceforge.net[^]. It has complete support for plugins, UI the lot. My help you what Eric meant in the port below. Just Remeber the interface is the most important part. I had made several interfaces , so some plugins can have a GUI and/or Menus or nothing at all. I must admit that was my 1st biggish C# project so some of the coding is shocking, but for you to see how I have done , it will suffice. Hope it helps :) Give them a chance! Do it for the kittens, dear God, the kittens! As seen on MS File Transfer: Please enter an integer between 1 and 2.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups