MEF for SL3

Oct 23, 2009 at 10:12 AM
Edited Oct 23, 2009 at 10:33 AM

Hi,

I'd like to create my first MEF+SL3 App with the latest MEF Version (beta) based on some tutorials given by Brad Abrams.

However, I could not find some classes like PackageCatalog in the SL-compatible DLLs given by MEF BETA .

I figured out that PakageCatalog was delivered in the previous released versions. It was however not included in the lastest version of MEF.

When I took a look at one of your examples, called PictureViewer, I found those classes Package, PackageCatalog, and PackageLoader in the library PictureViewer.Common.

Could you all explain me how I can begin develop a MEF+SL3 App without working around (re-using of those listed classes)?

 

Thank you so much

Steven

Developer
Oct 23, 2009 at 5:22 PM

Package/PackageCatalog are currently not planned to ship with the SL version of MEF which is why they have been removed. We left them in the PictureViewer sample so that you could copy the implementation and use them if you wanted. They are not necessary to use MEF on SL, you can still use the TypeCatalog, AssemblyCatalog and AggregateCatalog. You can also use Composition.Initialization.dll which contains PartInitilizer.SatisfyImports that allows you to easily get imports satisfied in Windows/UserControls and it will actually handle creating the catalog for you behind the scenes.

Oct 23, 2009 at 6:08 PM

PackageCatalog is great but is only required if want to download XAP files dynamically and add parts.

<This message brought to you by the Dept. of the Obvious :) >

Oct 26, 2009 at 11:37 AM

thank you all for your feedbacks.

It would be nice if the MEF Programming Guide could be updated with those information as well as explicitly point out the differences in employing MEF for every environment (SL as a medium/partial trust environment, WPF as a trust environment, etc.).

I've figured out some restrictions for using MEF with SL after reading the programming guide:

+ MEF does not support non-public composition (importing or exporting private members are not supported. Protected members were not mentioned in the Declaring Imports Guideline).

+ DirectoryCatalog can not be used.

If you can find something else, please share them. Thank you!