Kilitli A moan/rant about MEF....

  • 14 Mart 2012 Çarşamba 04:57
     
     

    I've been playing with MEF for around a week now. I've used IOC in the past so i'm familiar with the concept.

    I can see that there has been some good thought put into the design of MEF, but I have had so much trouble getting it running that I feel the general population will put it into the 'too difficult' pile and walk away (which would be a shame).

    My feeling is that it just needs a bit more work, and a bit more coherent documentation and examples to make it usable.

    Sure... there are a lot of examples out there and a lot of blogs, etc, but most of them just cover the sunny day basic scenario. If they are to be believed it is as simple as putting an [Export] attribute on a class and hey presto it gets magically created.

    The reality is you will lose hours trying to find out why it is sometimes working and sometimes not, and trying to work out where the multitude of code snippets out there actually go in the solution. Most of the examples don't compile, or target only silverlight (which, after several hours of downloading and compiling, I have come to realise means 'won't work with WPF').

    Today my solution stopped working. The error I was getting was that 'MEF was unable to find my module'. It was still in the same place it had been all day. After hours I stripped out masses of code to discover that the problem was to do with an import I had put in to my module ([Import] ICompositionService _cs;). When I commented this out it found my module again. I now wonder if all those other problems I have had have been related to similar problems, but been masked by bad error messages.

    For me it's just been a frustrating journey. Most things you can generally have up and running in a few minutes, or worst case scenario in a few hours. I think with this it's just not polished enough to be able to do that.

    However... as I said I think it's got great promise and i'm sure that in a few weeks I will have forgotten all these problems :)