4

I really like the plugin architecture of WinForms and I want to use a plugin architecture in Asp.net.

I've searched for plugins architecture in asp.net and I've found asp.net MVC samples, but I want to use classic asp.net project not MVC.

Does anyone know of any resources for patterns using classic asp.net, not MVC?

RickL
  • 3,318
  • 10
  • 38
  • 39
loki
  • 2,926
  • 8
  • 62
  • 115
  • There is no standard plug-in architecture per se. MEF (as Jan Remunda pointed out) is one option but it could be an overkill in some cases. What would you like to be able to do exactly. – Shiv Kumar Mar 09 '11 at 07:26
  • 1
    Especialyl given that there IS NO PLUGIN ARCHTIECTURE IN WINFORMS. What are you talking abuot? – TomTom Mar 09 '11 at 07:33
  • i wan to use plugin architecture in ASP.NET without asp.net mvc 1-2-3 – loki Mar 09 '11 at 07:44

2 Answers2

15

You can roll your own.

A plugin architecture needs a few not-so-complex parts:

  • A way to identify where the plugin dll is located
  • An interface or base class definition that all plugins must adhere to. This is the most important one. It decides what functionality your plugin can expose and how deeply it can integrate with your app
  • A place (in time) when your plugin gets loaded and executed. (ie, does the plugin execute for each web page request? Or for requests matching a certain name? Or does the page manually invoke plugins?)

Once you have this figured out, instantiating an instance of a plugin is simple. It works the same regardless of whether you're running in a web app or on the client:

System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(plugin_path);
t = a.GetType("IPlugin");
IPlugin plugin = (IPlugin)Activator.CreateInstance(t);

then, you can use plugin.DoSomething() to actually invoke functionality from the plugin. (Whether it is to render part of the html or save to a DB or whatever)

HS.
  • 15,442
  • 8
  • 42
  • 48
3

Look at Managed Extensibility Framework

Jan Remunda
  • 7,840
  • 8
  • 51
  • 60
  • without MEF can i do that? i am using vs 2008 – loki Mar 09 '11 at 07:21
  • http://stackoverflow.com/questions/740438/something-like-mef-managed-extensibility-framework-for-net-framework-2-0 – CD.. Mar 09 '11 at 07:40
  • yes, with reflection (as HS writes), but you have to write your own logic. MEF is better solution if you have bigger apllication with many components. – Jan Remunda Mar 09 '11 at 07:57
  • i want to use this solution in my project : http://stackoverflow.com/questions/236972/using-virtualpathprovider-to-load-asp-net-mvc-views-from-dlls – loki Mar 09 '11 at 08:11