Today I’ve been at a half day presentation given by Glenn Block who was until recently ‘the face’ of the Managed Extensibility Framework – MEF.
Before I get into the content I want to say I found the day really worthwhile and I am glad that I attended and just as I tweeted at the end of the day I have come away with the firm belief that in the future if you are doing dev on the .Net platform you may have to use MEF and I’ll explain more on that in a bit.
The event was held at Microsoft’s Thames Valley campus and the provision of coffee, Danishes and biscuits first thing was greatly appreciated.
The day kicked off with Glenn introducing himself, who he was, the fact he had worked outside of Microsoft creating commercial software and that he now was working on the WCF team.
Glenn then launched into the presentation and as a fair number of people in the audience hadn’t done any MEF at spent the first session running through the basics of imports, exports and composition. Nothing very earth shattering for anybody who has attended a user group meeting, web cast, read a blog or had a play with MEF itself and there were some comments from other attendees that they found this session a little boring but could see it was necessary for people who hadn’t seen MEF at all.
After a short coffee break we started the 2nd session which covered use of dynamic types, creation policies (shared, non-shared, any), CompositionInitializer in Silverlight and a community tool mefx that will help to find problems with composition showing the import and export of selected assemblies. Glenn kept reiterating that MEF was mainly designed for 3rd Party extensibility to allow authors other than the main software producer to extend existing or future products.
We broke again for more coffee, and came back for the third and final session. As we were running a little late Glenn then asked to hold all questions and he would do a Q&A session at the end, by doing this he was able to accelerate what he was showing us and abandoned the slide deck to jump between various demo solutions to explain the concept he was talking about. This session was very interesting covering topics ranging from Silverlight deployment catalogs to composable behaviours in WCF (Glenn’s latest thing he is working on) with a stop off at meta data and Lazy<T>.
With the demo’s over there was time for 30 minutes of Q&A which was just as interesting with people asking questions about security, preventing malicious code from an import, run time meta data, export providers and more. Each question was answered, even if the answer was it can’t be done but often suggestions for blogs to read that would provide in depth answers to the questions being asked.
Some of the most interesting nuggets came about during the Q&A or during the wrap up such as:
- MVC3 looking to use MEF
- Additional work being done with hierarchical containers around scope of objects e.g. in a web app have objects scoped to the life of the app, others scoped to the life of the session and others scoped to life of a request.
- Glenn mentioned that the ideal situation would be to build MEF ‘into’ the .Net framework and that it was being looked at.
What I’ve taken away from the day is the following:
- MEF was originally designed to provide easy extensibility for 3rd parties
- If you are building a new app don’t use IOC for dependency injection use MEF and compose
- MEF may well become a common foundation used in the majority of Microsoft technologies
It is for these reasons that I believe to dev on the .Net platform you should be looking to get a good handle on MEF and work out how to best leverage it not only when designing and coding your apps but when interacting with base functionality that is likely to appear in the framework itself.
Glenn said that he was going to enlighten us in the way of MEF-fu, well I think I’ve taken the first steps on the path but it could take a while to master it.
Some additional resources: