Still confused about MEF

Sep 11, 2008 at 2:28 PM
I wrote at this and this in Wes' Puzzleblock blog. And he directed me here . I am wondering that I am missing a huge idea behind MEF. But the examples that are provided looks quite similar to the one I had done.(Look at the second link).

What am I missing?

Also, I have to say that the code snippets are done without looking deep into MEF and as a  POC.
Sep 12, 2008 at 2:15 AM
Edited Sep 12, 2008 at 4:05 AM
As Wes said, your sample will work, but 1) what MEF provided is much more than instantiation and wiring-up. There are lots of other capabilities you can leverage on MEF such as lazy loading, metadata-based discovery, duck typing, catalog and so on 2) More importantly, with MEF you do not have to create your own plug-in infrastructure from scratch where your plug-in can only be used in your application (as your sample) or you have to duplicate your hosting code in every application.

You may find more detailed information in our wiki pages. Hope this answered some of your questions.

Thanks,
Zhenlan
Sep 12, 2008 at 2:53 PM
Thanks Zhenlan. My code looks app specific simply because I wrote it that way. Actually come to think of it, the code is generic from a Console application POV. It is a console app that will load any class that implements ITask, for now at the start of the app but that can be made dynamic. Also moving that to a separate Assembly and Gacing it would make it more generic.

I know I am showing off my ignorance but hey how else can I learn.




Acceptance is not my cup of Tea. :)
Sep 12, 2008 at 10:02 PM
Hi Ganesh, I absolutely understand your code is just a sample (a great sample!). It can be made much more complex to provide even more functionalities than MEF. Actually, this is what people are doing now - creating their own plug-in model infrastructure.

My question is - if there is a MEF already existing in your .Net Framework, do you have any interest to take advantage it? If not, can you let us know why? Your feedback will be very valuable for us to improve MEF.

Thanks for your feedback!

Zhenlan

ps. MEF also provides many extension points to itself so that people can customize MEF for their specific needs.
Sep 15, 2008 at 3:50 PM
The difficulty I face with MEF is I work on some prev versions of .net framework which might not work with MEF.Am I correct saying that?

In an enterprise, it is extremely difficult to switch to a newer framework that easily.


Sep 16, 2008 at 9:06 PM
Edited Sep 16, 2008 at 9:07 PM
Thanks Ganesh for your feeback! Yes, it is always hard to switch.

WRT your question, we are currently working hard to make it as simple as possible for people to create their custom programming models and resolvers. I am not sure about your specific scenarios, but with some customization of MEF, it is possible for people to take advantage of the MEF composition engine and have it working with existing parts.

Thanks,
Zhenlan
Sep 18, 2008 at 8:55 PM
Edited Sep 18, 2008 at 9:54 PM
Another issue that might crop up is something like,

A part of the same type as other parts implementing a same interface might use a specific assembly, say aSpecificAssembly.dll. In order to make the said part workable there should be a way of announcing the dependency to aSpecificAssembly.dll

How can this be done? If we do not do this, one has to wait till QA catching this.
Sep 18, 2008 at 9:26 PM
Another issue that might crop up is something like,

A part of the same type as other parts implementing a same interface might use a specific assembly, say aSpecificAssembly.dll. In order to make the said part workable there should be a way of announcing the dependency to aSpecificAssembly.dll

How can this be done? If we do not do this, one has to wait till QA catching this.