Click here to Skip to main content
15,867,870 members
Everything / MEF

MEF

MEF

Great Reads

by wells cheung
Angular Single-Page Application, MEF, Privilege Control, WCF Restful Service, ui-router,
by Dean Oliver
How we can harness the power of MEF and extend it by way of generics.
by Shuqian Ying
The source code and a simple demo program for a plug-in in Microsoft Managed Extensibility Framework (MEF) that provides visual display of email messages.
by Sau002
This article takes you through a step by step journey of building a fairly large console application which is modular and also extensible by using the principles of Managed Extensibility Framework.

Latest Articles

by Nicolas DESCARTES
How to build a plugin architecture in C# ?
by Sau002
This article takes you through a step by step journey of building a fairly large console application which is modular and also extensible by using the principles of Managed Extensibility Framework.
by GerVenson
An introduction into the Managed Service Extensibility Framework (MSEF)
by marceloarguello700
Load a Rhinoceros plugin through MEF

All Articles

Sort by Score

MEF 

29 Mar 2016 by wells cheung
Angular Single-Page Application, MEF, Privilege Control, WCF Restful Service, ui-router,
3 Apr 2014 by Kornfeld Eliyahu Peter
container.ComposeParts(this);...
2 Feb 2012 by Dean Oliver
How we can harness the power of MEF and extend it by way of generics.
31 Jul 2012 by Shuqian Ying
The source code and a simple demo program for a plug-in in Microsoft Managed Extensibility Framework (MEF) that provides visual display of email messages.
24 Jul 2019 by Sau002
This article takes you through a step by step journey of building a fairly large console application which is modular and also extensible by using the principles of Managed Extensibility Framework.
3 May 2012 by Shenwei Liu
The article series shows how to upgrade a Silverlight application having basic patterns to the MVVM and MEF composable patterns with easy approaches and detailed coding explanations.
23 Nov 2013 by Tomas Takac
How to inject named logger using MEF
13 Feb 2016 by Roger C Moore
Exploring Dependency Injection / Inversion of Control (IoC) with Managed Extensibility Framework (MEF)
7 Apr 2011 by OriginalGriff
Solved by the OP - answered to remove from unanswered list.
30 Nov 2011 by sucram
public string GetMessage {get;set;}Is not within a class you can not have a getter ans setter in the namespace.
11 Apr 2012 by Steve Maier
I have used MEF for a large medical system for sometime now. We also use a separate folder for the plugins. Actually we have multiple folders as well that various plugins are in. The only difference that we have from your setup is that the contract DLL is in our main folder, not a lib...
23 Jan 2013 by Harsh Baid
In this post, we will have more insights on the implementation part regarding multi-file assembly and using MEF to apply the concept practically in the applications using Directory Catalog technique.
18 Apr 2014 by Shai Vashdi
Hi Maurizio,Just look on my article: The Simplest Way to use MEF Fully Lazy DLL Loading[^]Use the "interfaces" approach for OOD pattern :)
4 Feb 2016 by Dave Kreskowiak
I seriously doubt you'll ever find one that covers all those topics in one plan.You'll stuff that covers sections of those topics, for example, Introduction to the .NET Framework, Introduction to C#, Unit Testing for Beginners, but you'll never anything that covers all of this stuff advanced...
22 Apr 2017 by bling
Understand than ANY approach you take is vulnerable to reverse engineering. The most you can hope for is to make it difficult but not impossible for someone to break your licensing mechanism. The best way to enforce licensing is to run everything on a server - forcing the clients to connect to...
17 Dec 2019 by ZurdoDev
The first google result for me is Managed Extensibility Framework (MEF) | Microsoft Docs[^] and has a section that explains those attributes.
19 Jan 2011 by hoernchenmeister
Hi all,I created an application that is able to load plugins and displays them.I now integrated Logging (Enterprise Library) into the mainframe which makes me start thinking how to pass the centralized loggin mechanism of the mainframe to the loaded plugins.Would it work to implement...
1 Jun 2011 by rashmih.in
Hi,I am new to MEF (Managed Extensibility Framework). I need to create a WCF service as a MEF container. Sample example would be great.I would appreciate the help.Thanks in advance.
1 Jun 2011 by #realJSOP
Like this?Creating WCF Service Extensibility through MEF (Managed Extensibility Framework)[^]
13 Oct 2011 by Quipsound
Hi thereI have a class decorated with the ImportingConstructor attribute as follows:[ImportingConstructor]public MyClass([Import("Path")]string path, [Import("Key")]string key)and can create an instance using CompositionContainer.GetExportedValue...
30 Nov 2011 by webpeon80
I get a red wiggly line under 'string' in the Import section (marked with a strikethrough in my code below) with the error "Expected class, delegate, enum, interface, or struct"anyone know where im going wrongnamespace MEFProgram{ [Import (typeof(IMessage))] public...
30 Nov 2011 by alexis.coles
Should the attribute not go above the class ? Just a guess..namespace MEFProgram{ public string GetMessage {get;set;} [Import (typeof(IMessage))] class Program {
30 Nov 2011 by Nikil S
This is often caused by an extra a closing paranthesis.Refer to the below answer for more information.Expected class,delegate,enum, interface,or struct[^]
30 Nov 2011 by Richard MacCutchan
"Expected class, delegate, enum, interface, or struct"But you have a simple method!
30 Nov 2011 by webpeon80
sorted... dropped the string line inside the program class and it cleared up, final code incase anyone runs into the same problemnamespace MEFProgram{ class Program { [Import()] string GetMessage { get; set; } static void Main(string[] args) ...
30 Nov 2011 by moneymakermaster
The property GetMessage is outside the class.At the namespace level there can be class,enum,interface or struct.Properties should be defined at class level
10 Dec 2011 by webpeon80
ok so if a standard n-tier architecture looks like thisWebBALDLLDatasourcewhat does an n-tier architecture using ado.net entity model and MEF look like..?
10 Dec 2011 by Not Active
Entity Framework is just a means of accessing the data, so it falls within the DAL, Data Access Layer. MEF is used is in the business layer.
26 Mar 2012 by Saroop Trivedi
I have a interface as follows: [InheritedExport(typeof(ITransform))] public interface ITransform {...}Now, I have two classes: namespace ProjectA { public class Transform:ITransform {....} } And namespace ProjectB { ...
27 Mar 2012 by pietvredeveld
I think the problem is in the return extensions.FirstOrDefault(); MEF will normaly return all the objects that match the requested import. Now only the first one it finds. You can add meta data and lazy loading to get the right object from MEF.PietPS: just read the solution given on...
28 Mar 2012 by pietvredeveld
Hi,I've look deeper into you're problem. It not a MEF problem. The problem is the loading model of .NET. (or better the way you're objects are loaded by .net)When MEF loads it returns the correct objects. But when looking for class ProjectXYZ when projectB is loaded there is already a...
11 Apr 2012 by hoernchenmeister
Hi all,I am dealing with MEF for quite a while now and was quite pleased with it.Since now I used a DirectoryCatalog that loaded dll's following a specific naming convention (all dll's/exe's etc in the same folder).Now I get the chance to structure something equal in a different way,...
27 Sep 2012 by VinVan81
Ok ... i solved it! \o/if any other guy has a similar problem, here's my code://An aggregate catalog that combines multiple catalogsvar catalog = new AggregateCatalog();//Adds all the parts found in the same assembly as the Program classcatalog.Catalogs.Add(new...
12 Jun 2016 by hoernchenmeister
Good morning all,I am struggeling with a strange problem using nested imports in MEF.I try to keep it quite basic, so I do not annoy you people with the details ;)Maybe somebody has experienced similar behavior, I just have no more clue where to look at.I have a ModuleImporter class...
8 Dec 2012 by FantasticFiasco
I thought it would be possible to write the following code:[Export]public class ClassA{}public class ClassB{ private readonly Func classAProvider; [ImportingConstructor] public ClassB(Func classAProvider) { this.classAProvider =...
31 Jan 2013 by Pete O'Hanlon
A while ago, I was lucky enough to work with the super smart Marlon Grech - the result of this work was this[^] project. If you need a WPF framework that uses it, take a look at Sacha Barber's excellent Cinch v2[^].
31 Jan 2013 by LOUIS Christian
Take a look on Prism on codeplex. MEF is integrated.http://compositewpf.codeplex.com/[^]
30 May 2013 by Sergey Alexandrovich Kryukov
Just start from here:http://en.wikipedia.org/wiki/Managed_Extensibility_Framework[^],http://msdn.microsoft.com/en-us/library/dd460648%28VS.100%29.aspx[^],http://mef.codeplex.com/[^],http://mef.codeplex.com/documentation[^].—SA
30 May 2013 by NightCodeStalker
Can you boostrap a Prism module system from within the WCF service? Because no matter what I do my MEF dependencies are not being fulfilled.E.g.:This is my WCF service implementationpublic class MyService : IMyServiceContract{ // This should get filled by MEF after Prism loads...
9 Oct 2013 by Ramana Bellary
Hi, I want to convert Lazy to Lazy where IOperationData and IOperation are interfaces.foreach (Lazy i in operations) { if ((i.Metadata as IOperationData).Symbol.Equals(operation)) ...
26 Nov 2013 by Member 9417653
Please under stand the flow of code . I have an interface Ishape which in some separate dll or class library. [InheritedExport] public interface Ishape { int Paint(int width, int height); }In my window application I have two classes. public class...
7 Jan 2014 by Gabriel Sas
Hello, i want to export a grid and to import it so i can use it in the MainWindow.I want to do this to use different controls on the MainWindow.And to make it usable for other programers to create their own grid to change the MainWindow based on a list of grids.Any simple...
22 Jan 2014 by Gabriel Sas
Hellocan a user control be exported? and how? or why can't it be exported? using MEF and WPFThanks,
17 Mar 2014 by Member 10678514
I need to create a system to execute some scheduled jobs.I considered it's a job for MEF.The idea is to have a central blok where I can attach some other components in the form of MEF plugins.For example I would like to have a class for data source, a class for data destination and a class...
28 Mar 2014 by ashok rathod
I am getting below Error while using MEF as a part of my project.What Could be the issue?The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the...
28 Mar 2014 by ashok rathod
The Problem was that i had many parts which needs to be included in container and for that I have to use ImportMany instead of Import[ImportMany] IEnumerable> operations;instead of [Import] IEnumerable
2 Apr 2014 by stubobis1
I am trying to learn dependency injection.Ive made a test app to try it out. The output should be "Testing Appended string", but it keeps giving me a NullReferenceException. Any help?using System;using System.Collections.Generic;using System.ComponentModel.Composition.Hosting;using...
30 May 2014 by Gabriel Sas
Is there a tool that can find out if i am using Export[typeof(IMyExport)] on multiple classes but i am only using this as [Import] IMyExport TestObject; and it should be used with [ImportMany]
3 Jun 2014 by Sergey Alexandrovich Kryukov
The question is way too vague to give the exact advice. You did not describe your existing architecture and what have you tried. You did not explain what could be your problem.But the idea could be this: you should remember that your windows service works even if there is no a desktop, so...
30 Jul 2014 by Omar Gameel Salem
Solving "The IControllerFactory 'MefContrib.Web.Mvc.CompositionControllerFactory' did not return a controller for the name xxx"
10 Sep 2014 by #realJSOP
VS2013, Win7 (32-bit)I'm writing a WPF app that utilizes MEF, and one of the modules (the one I'm testing) uses interop services. When I run the app to test the module, the app shuts down with no indication that anything is wrong. I've put try/catch blocks around the code where it stops, and...
29 Sep 2014 by Kurlyan
First thing's first, English is not my language, please forget my language mistakes.My idea:- How to separate business logic & ui to multi dll- How to plug/unplug application plugin when host application is running- How to Building some share dll for (Script, UI control, css)So,...
29 Sep 2014 by Nelek
Step 1) Do a little research. Google is a good start pointStep 2) Start codingStep 3) Compile and use the debug to solve little issuesStep 4) When you get a problem you don't know how to solve but at least you tried it, then come back and ask for something concrete with a snippet of the...
15 Sep 2015 by V3rius
Hello everybody,i have a project with a Datagrid (Host),another Project with an Interface(Contract) anda third Project (Plugin) which References the contract like the host.(All of them in .Net 4.6)Seems like normal MEF till now.I use EF6 inside the Plugin to get information for...
7 Mar 2016 by Yashashwi Srivastava
I have been practicing MEF for some time. But I always wondered about following questions. 1. The [InheritedExport] attribute, my questions is upto what level of inheritance is supported or is it configurable too? Can the child of the derived class be instantiated by exporting the great-parent...
8 Apr 2016 by marceloarguello700
Load a Rhinoceros plugin through MEF
9 Jan 2017 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null -...
21 May 2017 by Sabyasachi Mukherjee
I'm using MEF as the IoC container in WPF with Caliburn.Micro framework. The MEF container resides in the Bootstrapper. Bootstrapper has the method: protected override void OnStartup(object sender, StartupEventArgs e) { DisplayRootViewFor(); } Now,...
29 May 2018 by Boris Zinchenko
I have an assembly dynamically loaded through MEF. Inside the assembly I have dynamic objects reconstructed from JSON by Newtonsoft.Jnon like follows. JObject jObject = (JObject)JsonConvert.DeserializeObject(data); long id = jObject.id; This code compiles and runs fine on several machines...
6 Jul 2018 by canard29
Hi, I want first to thank @Graeme_Grant for his great suppport in this article https://www.codeproject.com/Questions/1250791/Load-usercontrol-by-reflection I copied the code, added the reference and everything is working well ! I have an additional question. I want to have access to the...
10 Jul 2018 by JohnMeers
I have an application using MEF and am trying to write integration tests for the Plug-ins. The code I have is:- public string Run() { IFunction IUT = null; string Wanted = "NewUser"; foreach (Lazy func in...
10 Jul 2018 by Graeme_Grant
You don't need to use reflection with MEF, you simply Export & Import to share data - the data can exist in a DLL/EXE outside of the main app. So long as MEF can compose, the data will be visible. This is what we did in another MEF Solution[^] where reflection was requested for a plugin system...
N 22 Mar 2024 by Nicolas DESCARTES
How to build a plugin architecture in C# ?
21 Mar 2011 by Nick Polyak
Prism for Silverlight/MEF in Easy Samples tutorial. Part 2 - Prism Navigation
3 Dec 2014 by John M. Baughman
Demonstrates using MEF in an AppDomain and allows the exchanging of MEF parts while the application is running.
1 Mar 2016 by Akhil Mittal
Resolve dependency of dependencies using Inversion of Control and dependency injection in Asp.net Web APIs with Unity Container and Managed Extensibility Framework (MEF).
28 May 2012 by db7uk
A composite (Prism 4) WPF application using Bing Maps to display earthquakes from around the world.
25 May 2014 by Vedat Ozan Oner
Arduino data logger implementation using WCF Windows services
26 Aug 2010 by Kunal Chowdhury «IN»
In this article, I describe MEF using a Silverlight Application. Read it and don't forget to vote and share your feedback.
5 Apr 2011 by fmsalmeida
In this article, I will show how to build a pluggable component using MEF.
27 Apr 2011 by Niladri_Biswas
This article will disscuss about MEF, how to start working in this, etc.
11 May 2011 by Super Lloyd
A much simpler composite application library.
9 Dec 2013 by Pete O'Hanlon
While we are all familiar with testing standard interface implementations, actually testing Lazy imports can be trickier if you don't follow this trick.
22 Oct 2014 by Vadym Rybak, Oleksandr Rogovskyi, Vladyslav Chernysh
Simple framework that enables your application to dynamically discover, load and unload plugins.
14 Aug 2016 by GerVenson
An introduction into the Managed Service Extensibility Framework (MSEF)
18 Apr 2012 by Dean Oliver
A short guide to what to look forward to in the next release of MEF.
1 Jan 2011 by Gareth Barlow (NBNi)
Building up activities using the Managed Extensibility Framework for workflow services hosted in IIS.
3 May 2012 by Shenwei Liu
The article series shows how to upgrade a Silverlight application having basic patterns to the MVVM and MEF composable patterns with easy approaches and detailed coding explanations.
5 Jun 2011 by stevenlauwers22
Creating an Elmah plugin for Glimpse
27 May 2015 by Arup Banerjee
The project is a simple Temperature Converter WPF Application which will allow user to convert from Celsius to Fahrenheit and vice versa. The objective however is to demonstrate techniques that are important when building large-scale front-end enterprise software.
3 May 2012 by Shenwei Liu
The article series shows how to upgrade a Silverlight application having basic patterns to the MVVM and MEF composable patterns with easy approaches and detailed coding explanations.
28 May 2013 by Hamed Musavi
Setting up MEF to load plugins from a directory
15 Mar 2012 by rawwool (Rahul Kumar)
Use Twitter as a globally available persisted message queue in your distributed applciation work flow
29 Nov 2011 by webpeon80
so ive setup an n tier infrastructure for a social network site im building, I have the following 5 projects im going to use.WEB - UIBLL - Business LogicComponents - will be discovered from 'Interfaces using MEFInterfaces - Plugins are discovered by Components using MEFDAL - Data...
7 Apr 2011 by Cr3at0rX
I´m trying to inject an existing instance of a class into my view, but the view only receive a default instance of my class.Here is my export in a view model class[Export("BLA", typeof(vmObject))] public vmObject VMObject { get { ...
2 Apr 2017 by VinVan81
Hello,i'm trying to implement a software by using the Managed Extensibility Framework (MEF). It's running but if there's a component in the directory, which exports an interface wich the container should import, but the implementation is not valid and implements only one method not in the...
5 Jan 2013 by Daniele Fusi
Hi all, I've been googling a lot about this but it seems there is no up-to-date solution (e.g. see here[^]). Basically I'd like to build an MVC 4 web app acting as a host for plugins. Each plugin should expose controllers (exported via MEF into their DLL) plus content files (views and the like),...
21 Apr 2013 by RowanArkison
Hi@all!I have a service, which uses user defined object providers (e.g. logic to access different data sources) by [ImportMany]. Since I want to use the default PRISM ILoggerFacade within the IObjectProvider Implementations, I have set up the importing constructor like this: ...
6 Feb 2011 by kishore Gaddam
Advanced MEF Programming
25 Aug 2010 by kishore Gaddam
Introduction to MEF Programming
3 Apr 2014 by Sergey Alexandrovich Kryukov
You did not show where the exception with the message "Object reference not set to an instance of an object" is thrown. Not to worry. This is one of the very easiest cases to detect and fix. It simply means that some member/variable of some reference type is dereferenced by using and of its...
23 Dec 2010 by Sergey Alexandrovich Kryukov
You're "pretty sure", but I would check up: in your implementation class, totally disregard "using" clause and write all fully qualified names -- should show the source of the problem.
4 Feb 2016 by Yashashwi Srivastava
This article is a brief insight into building composite application using Prism, MVVM design pattern.
27 Nov 2012 by Milan Raval
Advancements in MEF in .NET 4.5.
6 Dec 2010 by ImedRidene
Hi all,I have the following interface:public delegate void NotifyOnModulesAvailabilityHandler(Lazy[] modules);public interface IModulesLoader{ event NotifyOnModulesAvailabilityHandler NotifyOnModulesAvailability; Lazy[] Modules { get; set;...
24 Jul 2011 by Mahadesh Mahalingappa
MEF with WCF
18 Apr 2014 by Shai Vashdi
Hi Gablriel,Yes, a User Control can be imported. I wrote an example just for that in my article:The Simplest Way to use MEF Fully Lazy DLL Loading[^]
18 Apr 2014 by Shai Vashdi
Hi Andy,Take the simple solution, just use a generic MEF importer & loader. I hope my article can help you:The Simplest Way to use MEF Fully Lazy DLL Loading[^]Best Regards,Shai
18 Apr 2014 by Shai Vashdi
Hi,Just use the meta data for example:[ExportMetadata("Name", "ControlsLibrary1.BlueControl")]Then when you load all of the Shapes you can add them to the Combo-Box.You can read more about it in my article:The Simplest Way to use MEF Fully Lazy DLL Loading[^]I hope it...