Create An "add-in-able" Application
-
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
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.
-
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.
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
-
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
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
-
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
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
-
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
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
-
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
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.
-
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
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
-
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.
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
-
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
Interesting idea. Do you have a suggestion on how to handle separate GUI components for each of the plugins? Mike Stanbrook mstanbrook@yahoo.com
-
Interesting idea. Do you have a suggestion on how to handle separate GUI components for each of the plugins? Mike Stanbrook mstanbrook@yahoo.com
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.