How to develop dynamic functionality based on plugins in C #

I was looking for various ways to provide plugins for my application. Ideally, I will create basic functions and will be based on different clients developing various plugins / add-ons, such as import, data export, etc. What are some of the methods available for building a C # application using the plugin architecture?

Let's make an example. If we have a program consisting of the main menu (File, Edit, View, et al.) Together with TreeView, which displays various brands of cars grouped by manufacturer (Ford, GM, for now). Right-clicking on a car displays a context menu, the only option of which is “delete car”.

How could you develop an application so that plugins can be deployed so that you can let one client see a new brand in TreeView, say Honda, and also expand the car’s context menu so that they can now “paint the car”?

In Eclipse / RCP, this is easily handled by extension points and plugins. How does C # handle it? I studied developing my own plug-in architecture and reading on MEF.

+6
c # plugins dynamic menu extensibility
source share
2 answers

MEF would be a good place to start.

Glenn Block Article Managed Extensibility: Creating Composite Applications in .NET 4 Using Managed Extensibility Framework gives a good overview.

By the way, don't be fooled by the header - you can also get MEF for .NET 3.5 SP1.

+10
source share

Visual Studio 2010 uses MEF, so I believe that this is a safe bet, this is the preferred way to switch to MS. System.Addin always seemed a little heavy, but it might be the best choice if you need add-ons to always work and your code base is constantly evolving.

If you are interested in isolating add-ons, you should read on AppDomains. I have a demo project that I did to help learn how to deal with isolate assemblies in AppDomain here that may seem interesting to you. Brief information about isolation: only your types should cross the border, and these types should be sealed, trigger a scream when processing events with cross domains, and additions should not extend MarshallByRefObject.

+1
source share

All Articles