MEF 2.0 – mini series: part 4 (Fluent Import)

Saturday, January 12, 2013

MEF 2.0 - mini series: part 4 (Fluent Import) this is the 4th post in the MEF 2.0 mini series. you can see the following TOC for other posts in this series. in this post I will discuss the Fluent import API. we was talking about Fluent Export and Constructor Injection in the previous posts. this post will complete the main scenarios of Import's fluent API. I will demonstrate the import technique using the following classes: Code Snippet public class Foo {     public Logger Log {...

MEF 2.0 – mini series: part 3 (Fluent import constructor)

Wednesday, January 9, 2013

MEF 2.0 - mini series: part 3 (Fluent import constructor) this is the 3rd post in the MEF 2.0 mini series. you can see the following TOC for other posts in this series. in this post I will discuss the fluent constructor injection API. Constructor Injection the following code is having a Logger and Worker class which is having 2 constructor (one has no parameters and the other is getting ILogger): Code Snippet   public class Logger: ILogger {     public void Write(string message) {...

MEF 2.0 – mini series: part 2 (Fluent and Conventional Export)

Sunday, January 6, 2013

MEF 2.0 - mini series: part 2 (Fluent and Conventional Export) this is the second post in the MEF 2.0 mini series. you can see the following TOC for more. in this post I will start to cover the fluent discovery model and the idea of discovery by convention. traditionally, out of the box, MEF come with a single discovery model, which was the Attribute model. it is true that you could extend MEF's discovery model by using either a custom catalog or a custom export provider, but...

MEF 2.0 TOC

Portable MEF (Microsoft.Composition) Part1: Attribute Model Part2: Convention Part 3: Dependency Injection vs. Service Locator Part 4: Microsoft.Composition (Portable MEF): Scoping   MEF 2.0 (Full Version) TOC MEF 2.0 is a reflection of a community requests. features like Open Generics, fluent and conventional discovery, lifetime handling of the part, better exception handling and more, was all requested by the community. part 1: Open Generics Part 2: Fluent and Conventional Export Part 3: Fluent import constructor Part 4: Fluent import Part 5: Fluent export properties. Part 6: Composition scoping and lifetime management ...

MEF 2.0 – mini series: part 1 (Open Generics)

Friday, January 4, 2013

MEF 2.0 - mini series: part 1 (Open Generics) this is the first post of a new mini series about MEF 2.0. MEF 2.0 is a reflection of a community requests. features like Open Generics, fluent and conventional discovery, lifetime handling of the part, better exception handling and more, was all requested by the community. each post of this mini series will target a single enhancement. Open Generics one of the most annoying missing feature in MEF 1 was the lack of support for Open generics. the...

MEF – Best Practice

Wednesday, July 27, 2011

MEF - Best Practice In this post I will offer MEF practice that may ease your MEF life. one of the MEF headache is to understand what's goes wrong, when MEF reject the composition, you can read more about MEF diagnostic in this post.  Most of the obscure loading failure happens when your Export dependencies doesn't satisfied. in those case you solely relay on the MEF error message which is not enough in cases of deep dependencies graph. It will normally occurs when you...
no comments

SDP – MEF (Real-Life patterns)

Friday, March 18, 2011

SDP - MEF (Real-Life patterns) On the last day of the SDP at Crown Plaza Hotel, Tel Aviv. I was lecturing about Real-Life scenario of MEF failures. the lecture was focusing on diagnostic ,solutions and testing. I want to thanks all attendant's, It was the after lunch session and you were bravely kept your eyes open.   the presentation pdf can be found here.   you can use the following check-list as recommended diagnostic process.   Diagnostic Check-List Is the instance included...

Dynamic MEF isn’t thread safe by nature

Saturday, December 4, 2010

Dynamic MEF isn't thread safe by nature this post focus a pitfall which you should be aware in order to avoid sporadic crashes. In general most of MEF operation are operate once at the application initialization stage, and it normally happens on a single thread.   this may not be true when you need to dynamically load MEF parts (using GetExportedValue or SatisfyImportsOnce).   unfortunately MEF underline is using non concurrent dictionary which is not thread safe for the above operation implementation. therefore the following code will crash sporadically. Code Snippet // exported type...
10 comments

Exporting non Exportable types

Saturday, October 30, 2010

Exporting non Exportable types this post extend Glenn Block's post about "Poco, Mef, and custom type systems. Are you ready to take the red pill?"  the post is adding a compile time attribute export model, Directory catalog and migrate Glenn code to VS 2010. It is very recommended to read Glenn Block's post before reading this one.   the code sample for this post can be download from here.   Summarizing Glenn's post in general Glenn show how to add attributes (like Export) to...

Testing and Debugging MEF, avoiding misconceptions – Part 3

Friday, October 29, 2010

Testing and Debugging MEF, avoiding misconceptions - Part 3 this is the 3rd post of this series and it will discuss common misconceptions which may lead unexpected behavior and long debugging nights.   Initialization issues the first misconception occurs when developer are trying to access imported property at construction time. NullReferenceException public class MyPlugin {     public MyPlugin()     {   // the logger import doesn't satisfied yet         // the next line will result with NullReferenceException         Logger.Write("MyPlugin initialized");     }            public ILogger Logger { get; set;...