Pocket MEF CTP 8


one comment

Pocket MEF CTP 8

I finally found the time for updating Pocket MEF to the CTP 8 version.

the new version is available on codeplex.

if you were using the previous version I encourage you to switch to this version.

this version is match closer to the full framework version bits and it is better testes.

pocket mef


What’s new on this version?

Pocket.ComponentModel.Initialization is now supported:


you can use the PartInitializer to satisfy your object without having instance of the container.

the difference from the Silverlight version is that the entry assembly is not part of the default container’s catalog.

the only default catalog is Parts relative directory which you can drop compostable assemblies without needs for custom setting.


the CompositionHost can be use for setting the default container (which is used by the PartInitializer)

see the following code snippet (place the initialization code at the start of the Main method):

Code Snippet
  1. var catalogs = new AggregateCatalog();
  2. var catalogAssembly = new AssemblyCatalog(Assembly.GetExecutingAssembly());
  3. var catalogFolder = new DirectoryCatalog(PLUG_INS_FOLDERS);
  4. catalogs.Catalogs.Add(catalogAssembly);
  5. catalogs.Catalogs.Add(catalogFolder);
  6. var container = new CompositionContainer(catalogs);
  7. CompositionHost.InitializeContainer(container);


Metadata support: 

the next major change of this version is the metadata support.

using strong typed metadata on the full framework version is using Reflection.Emit which is not supported on the Compact Framework.

to resolve this issue you should register a mapper that know how to convert the metadata into your strongly typed instance.

the mapper should implement the following interface:

Code Snippet
  1. internal interface IMetadataViewProvider<TMetadataView>
  2. {
  3.     TMetadataView GetMetadataView(IDictionary<string, object> metadata);
  4. }

use the following sample for registering the mapper into the framework:

Code Snippet
  1. MetadataViewProvider.RegisterProvider<ICustomMetadata>(MetadataViewProvider_ICustomMetadata.Instance);

to make the mapper creation task easier you can find code snippet that will help you with that task,

the code snippet available both as part of the source code and as separate  download



Point of interest

if you living in Israel you can hear me speaking on MEF at the SDP


Digg This
Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


one comment

  1. Sven2014/03/14 ב 15:02


    I’m using Pocket MEF and it’s great. Thanks for your effort.

    But I have a Problem. You’re talking about (and the error message says) that we should use MetadataViewProvider.RegisterProvider.
    But it’s not possible because MetadataViewProvider is marked as internal. Is there any other way to Register Metadata?