Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plugin-like architecture in .NET

I'm trying to implement a plug-in like application. I know there are already several solution out there but this is just going to be proof of the concept, nothing more. The idea would be to make the application main application almost featureless by default and then let the plugins know about each other, having them have implement all the needed features.

A couple of issues arise:

  1. I want the plugins at runtime to know about each other through my application. That wouldn't mean that at code-time they couldn't reference other plugin's assemblies so they could use its interfaces, only that plugin-feature initialization should be always through my main app. For example: if I have both plugins X and Y loaded and Y wants to use X's features, it should "register" its interest though my application to use its features. I'd have to have a kind of "dictionary" in my application where I store all the loaded plugins. After registering for interest in my application, plugin Y would get a reference to X so it could use it. Is this a good approach?
  2. When coding plugin Y that uses X, I'd need to reference X's assembly, so I can program against its interface. That has the issue of versioning. What if I code my plugin Y against an outdated version of plugin X? Should I always use a "central" place where all assemblies are, having there always the up to date versions of the assemblies?

Are there by chance any books out there that specifically deal with these kinds of designs for .NET?

Thanks

edit: I think people are drifting away from the 2 questions I made. I can take a look at both MEF and #develop, but I'd like to get specifics answers to the questions I made.

like image 634
devoured elysium Avatar asked May 07 '10 21:05

devoured elysium


People also ask

What is plugin based architecture?

● The Plugin architecture pattern consists of two types of architecture components: a core. system and plug-in modules. Application logic is divided between independent plug-in. modules and the basic core system, providing extensibility, flexibility, and isolation of. application features and custom processing logic.

What is .NET plugin?

The plugin framework is a NuGet package that allows you to customise and extend a . NET application at runtime. Code examples are provided for ASP.NET Core, Blazor, Console Apps and WPF & WinForms. The plugin framework package can be installed from NuGet and also supports the delivery of plugins from NuGet.

What are plugins in C#?

In today's article, we will take a look at using the plugin pattern in C#. The plugin pattern allows us to drop assemblies into a particular location and use their implementation in our applications. This is one way we can create loosely coupled applications.

What is plugin MVC?

The ASP.NET MVC plugins is actually a extension based on another plugin framework OSGi.NET, technically, you can replace it with any other frameworks like MEF, Sharp-develop with some wrapping.


2 Answers

I recommend looking into MEF. This is a new way of doing plugins in .NET. It is the recommend way of doing new addins for VS2010, for example. I've not used it myself, but what I've looked into about it looks great. Adding this as an answer on prodding of others :)

like image 139
Matt Greer Avatar answered Oct 10 '22 11:10

Matt Greer


Look into the System.AddIn namespace. It's a little lower-level than MEF, and so should give you the "implement it myself" experience you're looking for.

like image 37
Joel Coehoorn Avatar answered Oct 10 '22 11:10

Joel Coehoorn