ASP.Net MVC 5 MEF how to programmatically import and export parts?
Asked Answered
H

0

1

I had read all of the many posts here on Stackoverflow on how to use MVC with MEF and have links for those, what I had not found an answer to in all of the questions and searching the internet is how to create plugins with MEF that can be Turn on,off, install, and uninstall from an Admin setting page.

I am trying to create my own CMS for MVC and would like to use MEF as part of my plugin framework.

Just need to know how to programmatically install, uninstall, turn on, and turn off the plugins that are made for MEF.

Thinking of writing "Plugins" to use MEF and then package that into Nuget where it can be installed and uninstalled from the Admin setting page.

Nuget would be responsible for Installing and Uninstalling

MEF would be responsible for registering the plugin, and some how have options to turn it on and off.

Example Situation:

  1. User install CMS

  2. User goes to Admin Section --> Plugins

  3. User sees a list of Plugins that they can install and use for the CMS

  4. User click "Install" and the MEF plugin is installed into the CMS

  5. User Click "Turn on" and the MEF plugin is ready to be used by the system

  6. User wants to temporary turn off the plugin, user clicks "Turn Off"

  7. User no longer needs the plugin and clicks "Uninstall" and the plug-in is deleted completely from the CMS system.

  8. User realizes that they accidentally deleted the wrong plugin, user clicks again "Install".

Goal is to be able to control plugins from an Admin settings type of page being able to install, uninstall, turn on, and turn off would be a great feature to have in a CMS.

I know other CMS uses this type of functions for their plug-ins but don't know of any that Uses MEF as part of their framework to do this.

Most uses their own internal Plugin framework for these functions.

I am hoping to be able to use the MEF framework to help do this.

An other goal is to basically have a system where "Plugins" targeting MEF and packaged in Nuget can basically be hosted some where like Nuget.org.

In the Nuget Package, with MEF everything that the "Plugin" needs is contained within the Nuget Package.

But, because it is using MEF, this package can technically only contain 1 DLL and when a user install the Nuget Package MEF will register the dll with their website.

Example could be a Blog, in the package it contains everything that is needed.

User goes to Visual Studio Install Nuget Package "Blog" and it install 1 dll that contains everything that it needs.

MEF will register the package with the user website and that is it.

No configurations or anything on the user side.

Just Pull and install from Nuget and that is it :)

Hayfield answered 26/7, 2014 at 13:40 Comment(5)
I am looking to do the same exact thing. If I find something, I'll come back and reference it.Parnas
I find this webpage useful: Fun with ASP.NET MVC 3, MEF and NuGet slideshare.net/maartenba/fun-with-aspnet-mvc-3-mef-and-nugetHayfield
I like the idea of using Nuget to "Package" the MEF which Nuget will deal with the install and uninstall functions of the "Plugin" Package. MEF will deal with the registering, turning on and off of the plugin. That is the theory part of it just need actual code of this :)Hayfield
Only reason NuGet doesn't work for me is that we plan on selling the "extensions" as upgrades to our base package. So we would like to retain control of the areas and compile them into separate assemblies so they can be distributed and activated by our sales staff.Parnas
Why don't u look at orchard CMS ? It's a great implementation with the ability to enable/disable modules at runtime. I can build your custom modules as orchard modules.Counterglow

© 2022 - 2024 — McMap. All rights reserved.