Oct 26, 2009 at 5:09 PM
Edited Oct 26, 2009 at 5:16 PM

im so confused.. has CompositionContainer.ComposeParts() been removed from preview 8? i use it in another project that uses the .net4 version of mef, but it doesnt seem to be in preview 8.. read somewhere that there where no major changes in preview8 and also that its supposed to be the same as the beta2 release.. what am i missing? and if im not supposed to use ComposeParts, what am i supposed to use? the samples seem to use ComposeParts still, but the msdn docs doenst seem to include it.. and yet its in beta2.... does not compute....

you really really need to sort out your docs and samples..... you cant possebly belive mef will have any kind of adoption with this kind api movement /docs quality. and no, beeing open source is not an excuse, you still have to finish stuff.

Oct 26, 2009 at 5:15 PM

oh ok, ComposeParts is an extension method, that explains why i didnt find it at first, but am i supposed to use it? it seems to be added as an after thought since its not in the CompositionContainer class, or is it? are any of the samples up to date and an exampel of the recomended procedure for bootstrapping mef? if so witch one?

Oct 26, 2009 at 6:38 PM

If you plan to on using our Attributed programming model (i.e. Import/Export attributes) then using ComposeParts is perfectly fine. ComposeParts is tied to our attributed programming model which is why it is an extension method located on AttributedModelServices and not directly on CompositionContainer directly.

Boostrapping MEF really depends on what kind of application you are using (i.e. console/winforms/wpf/sl) but in general it entails either pulling the host/root object from the container via container.GetExportedValue(...) or manually constructing the host/root object (or the framework constructing it in WPF/SL Application case) and calling either container.ComposeParts(...) or container.SatisfyImportsOnce(...) on the host/root object instance.


Oct 26, 2009 at 10:39 PM

i see.. ive read some code and calmed down a bit now :P things are a little clearer, but still you guys should consider pulling the examples of the site because when they arent in sync with the downloaded samples its just confusing :)

ive heard about the attributed programming model and i mostly get that i think, but what are the other programming models? i though mef was all about attributes, is that not so? i suppose that if you create your own export providerthat doesnt use attributes, that is not the attribute model, but doesnt composeparts work in those cases?

Oct 27, 2009 at 1:03 AM

MEF currently only contains one programming model, the attributed one, however that model is built on top of a primitives layer. The primitives namespace which contains things like ComposablePart, ComposablePartDefinition, ExportDefinition, ImportDefinition ComposablePartCatalog is what the CompositionContainer and our ExportProviders use, they don't know anything about attributes. Currently the only code that knows about the attributes is our TypeCatalog which constructs a set of *Definitions from types by translating the attributes into the associated *Definition properties. ComposeParts takes an object and assumes that the attributed programming model is used and constructs an appropriate ComposablePart based on the attributes, which is why it is an extension method on AttributedModelServices.

So while there currently aren't any other programming models that ship with MEF there is the possibility for more in the future and for other people to create them.

Hopefully that helps some.

Oct 27, 2009 at 11:34 AM

i see, that, along with some code diving makes it alot clearer, thanks :)