tags:

views:

48

answers:

1

Hi

Does anyone have any examples of using MEF in an XBAP application? Is it even possible?

  • UPDATE *

It looks like it is possible, but the location of the component parts is probably different than a 'normal' MEF application. So it looks like the following code isn't quite right - can anyone suggest a change to make it load properly ?

      var catalog = new AggregateCatalog();
        //Adds all the parts found in all assemblies in 
        //the same directory as the executing program
        catalog.Catalogs.Add(
         new DirectoryCatalog(
          Path.GetDirectoryName(
           Assembly.GetExecutingAssembly().Location)));
        catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
        catalog.Catalogs.Add(new AssemblyCatalog(typeof(IPageInterface).Assembly));

        container = new CompositionContainer(catalog);
        CompositionBatch batch = new CompositionBatch();
        batch.AddPart(this);

Thanks