MEF & Silverlight 4 Beta - Part 2, Imports & Exports

Play MEF & Silverlight 4 Beta - Part 2, Imports & Exports

The Discussion

  • User profile image

    Very cool!

  • User profile image

    This was a great refresher for me, however, if I hadn't been playing with MEF for awhile, I can't see how a someone new to MEF could possibly follow this.

  • User profile image

    Hi Sam,


    Ah - my apologies. If you could let me know whether it's

    1. Too fast
    2. Too deep
    3. Assumes too much knowledge of MEF - too little conceptual stuff up front?
    4. Too much code
    5. Too simple - i.e. using such a simple example causes confusion

    or something else that makes this not work for you then that'd be great and I'll take that on board for future work.


    If other people want to chip in as to whether they were new to MEF and whether they could follow what was going on, that'd be helpful.





  • User profile image
    mike kidder

    Mike I would have to disagree with Sam on this.   Your video tutorials are fantastic and perfect to get a real understanding of what MEF can provide.   I can only point to a hand full of video tutorials that are of this cabiler; yours is top notch!


    Thank you very much for these!

  • User profile image

    Hey Mike,


    Excellent stuff as usual. Apart from looking at part one, I haven't looked at MEF at all and I was able to follow it no problem.  If the problem is lack of background, then there are better places to get the in depth theory of why MEF is useful than here. For me, it's perfect pace and content. Loving it.



  • User profile image

    I think you missed my point, it worked GREAT for me, but if I had seen this when I knew nothing about MEF, I don't think it would have been as effective.


    I reference the pace with which you presented Unity.  I had never used or looked into Unity, and I got it clear and clean.


    I have to admit, this is total opinion because I can't unlearn what I already knew about MEF, so the better judge would be someone fresh to the subject.


    @Mike Kidder - While you may disagree, you provided no basis for that disagreement.  The only possible metric would be that you knew nothing about MEF, and got a good grasp of it here.  If that was the case, you should have stated it, and if that is the case, you would be the person with the superior view of the way it was presented.


    @Whirily - Perhaps if you re-read my post you might have a better understanding of what I said.  Your assumption is totally off.


    Too bad there wasn't a test at the end of the video, lol.

  • User profile image



    I really liked these videos.  It is probably the most detailed MEF video/intro that is out there.


    MEF is not for beginers and it should be noted as an "advanced" topic.  Devs who are not familiar with attributes, interfaces, lazy loading patterns, Silverlight app structure and to some extent Visual Studio 2010 are simply going to be scratching their heads after the first few minutes.


    The only feedback I would give is to possibly the source code for each video (as you state, you change the code from video to video in some cases) and if someone created a lab for this that would be great as well.


    The next evolution of MEF needs to be some "best practice" guidance from Microsoft on using MEF.

  • User profile image

    Hi guys,


    I'm brand new to MEF and just saw these first two videos.


    First, Mike - awesome videos - I agree with everyone else here, yours is an example for all other tutorials on channel9 to follow!


    Second, in response to the comments about whether a noob could follow this at all: I am definitely a noob to MEF, having never heard of it until I came across these videos. However, I'm not a junior developer at all, and I also have a good deal of experience with other Dependency Injection / Container frameworks. Currently in my projects I'm using Autofaq.


    So, I've had no trouble following any of the concepts presented so far, even though its the first time I'm seeing MEF, and I've also just barely scratched the surface of Silverlight and VS2010 also. As I'm watching, I'm comparing to Autofaq and other frameworks to get a sense of how MEF offers similar features.


    But I would agree, anyone completely new to both MEF and DI/IOC would probably be a bit lost, not because MEF is particularly hard to use (it's not) but because DI/IOC are pretty tough for developers to get to grips with at first, and there's really no easy way to just "dive right in" with someone who is still thinking in terms of passing dependencies around.


    So far I really like what I see, but admittedly the controversy is going to come out as we get to the more advanced concepts. Looking forward to continuing on though, and I'm already considering how I could go about ripping out Autofaq and replacing it with MEF in my current project.


    I do have one question though: watching these videos, and also reading through some of the content on the MEF homepage, I don't really see any mention of DI/IOC as concepts, and while most DI frameworks seem to use more or less the same terminology (Containers, Singletons, Prototypes, etc.), MEF seems to have invented a completely new set of terminology for what appear to be all the same concepts. I am still new to this, but so far my conclusion is that either (1) the developers of MEF have no idea that they are reinventing the wheel (but potentially much better); or (2) this is the intention, but all of the theoretical stuff has been purposefully left out in the videos and in the content, to avoid further confusing noobs; or (3) I'm completely misunderstanding things, and MEF is not intended to have anything to do with DI/IOC? Please enlighten me!




  • User profile image



    Thanks for the feedback - really useful for me to get that view so much appreciated.


    To answer your question - the answer is pretty much (2). I made a conscious decision to try and avoid saying DI and IoC with these videos. I wanted to try and introduce MEF as a practical technology for extensible applications without getting too bogged down in DI/IoC.


    I made some videos about Prism and Unity and I spent maybe 1-3 whole videos trying to talk about dependencies and getting to the idea of IoC and containers like Unity and;


    1) I felt that to do that again here would involve some repetition.

    2) I got some feedback on those videos from some folks saying "Hey, I know what DI and IoC is - you don't need to spell it out".

    3) MEF is not "just" about DI/IoC and so I didn't want to muddy the water by starting from that point-of-view.


    So, I tried to do what you say in your point (2) above.


    Now, I'm not a developer on MEF so I can't really answer point (1) but I can say that I feel >100% confident that the MEF guys "get it" ( a lot better than I do, I should add ) and they understand the landscape around their framework. I'd recommend looking at Glenn's blog for discussions around IoC as he has quite a lot of deep discussion on there.


    Hope that helps!



  • User profile image

    Mike,  I have to say I was scratching my head until I watched this video and then suddenly (thanks your vids) it clicked for me.  Thanks. 


    I will now watch the remaining vids and see if they sink in as easily. 


  • User profile image

    Hi Mike. 


    Your screencasts are fantastic!  Thanks for pulling all this MEF content together.


    I am brand new to MEF and DI/IoC in general.  I noticed during the second screencast that you used the debugger to determine whether a lazy instance of two objects of the same type was shared on construction or whether two distinct instances were created.  I was wondering - why and when would you want the option to do this ?

  • User profile image

    Hi sdbps,


    If you imagine that you've built a "data access layer" that surfaces a table ( e.g. "Customers" ) into the application and that layer does smart things around ensuring consistency and caching and so on then you'd probably only want one instance of this composed into the application so that all the code dependent upon it sees the same consistent data.


    Let's say you now have the option to display a view of that customer data in a grid and the user can open as many of these grids as they like in the UI and the view tracks things like the currently selected customer. Whilst the underlying data is the same, the state for each view (such as the selected customer) is separate so you'd want to have each view be a new instance rather than a single shared instance.


    Hope that helps.





  • User profile image



    I think these videos are really great. There is so much confusion about MEF and here you dive into details of what it can really do from practical point of view. This is really in your stile of explaining practical side of technology. However your videos still leave me wonder what MEF really is for .NET from architectural point of view. MEF codeplex site attempts explaining it, but it doesn't seem clear to me. It seems like MEF is really abstract componentisation approach of whole .NET (with one default implementation). However this implementation seems to be replacing such existing frameworks as Unity. May be new video on architecture? Wink

  • User profile image



    Think "plug-ins" and think "web deployment" - a Silverlight application can be factored into a set of pieces that are (potentially) separately deployed and downloaded on demand and these are then composed by MEF giving the potential for the functionality of the application to evolve as more components become available. That's all possible without having to write any explicit registration code for the components that are making up the application - all those components need to know is what functionality they provide and what functionality they consume.



  • User profile image

    Wow, kudos to you! Best screencast I've seen yet.


    FYI: I am new to MEF but I've read some articles about IoC/DI in general and your screencast is right on target, I can't think of a thing to improve it. I am looking forward to watching your other vids seeing what other cool stuff MEF can do!

  • User profile image
    Thundar Viking

    I just followed the entire video and coded along. It works great, but there was one bit I couldn't implement. The PartCreator class was not found on my machine, I am using the latest, official version of MEF that is shipped together with Visual Studio 2010.

    By the way, this video demonstrates some more advanced concepts in MEF like lazy initializations and custom export attribute. I found the video to be a good learning experience and the narrator has a good way of communicating difificult concepts in a clear and concise manner.

  • User profile image

    You are the BEST

Add Your 2 Cents