How to use ApplicationCatalog from MetroApp?

Mar 14, 2012 at 3:00 PM

Hello,

since some time, I try to get ApplicationCatalog and CompositionService.SatisfyImportsOnce() working, out of a Metro app. Does MEF2 support to load (extern) extensions out of an Metroapp?

Currently the following code just raises a NotSupportedException:

ApplicationCatalog catApp = new ApplicationCatalog();
_compositionService = catApp.CreateCompositionService();
CompositionService.SatisfyImportsOnce(this);

If there is a way to load extensions out of a class library any samplecode would be fine!

Thanks and best regards,

Jan

Mar 14, 2012 at 4:20 PM

Hi Jan,

I’d expect your code below to work fine – are you able to send some details of the exception, e.g. from where it is being thrown?

MEF in Metro style apps only supports the loading of assemblies that are packaged with the app directly.

Hope this helps,

Nick

From: Jank27 [email removed]
Sent: Wednesday, March 14, 2012 7:00 AM
To: Nicholas Blumhardt
Subject: How to use ApplicationCatalog from MetroApp? [MEF:348566]

From: Jank27

Hello,

since some time, I try to get ApplicationCatalog and CompositionService.SatisfyImportsOnce() working, out of a Metro app. Does MEF2 support to load (extern) extensions out of an Metroapp?

Currently the following code just raises a NotSupportedException:

ApplicationCatalog catApp = new ApplicationCatalog();
_compositionService = catApp.CreateCompositionService();
CompositionService.SatisfyImportsOnce(this);
 

If there is a way to load extensions out of a class library any samplecode would be fine!

Thanks and best regards,

Jan

Mar 14, 2012 at 5:41 PM

Hello Nick,

the Exception throws, while calling CompositionService.SatisfyImportsOnce(). The Exception Message is "Assembly.LoadFrom is not supported in AppX." Same problem occurs when I delete all dlls and WinMD files. It seems that ApplicationCatalog is not supported in an Metro App, is it?

My solution consists of two projects, the core project (including the Interface "IExtension") and an example project for a extension (Metro app class library) with one class, which implements IExtension.

Do you mean with "MEF in Metro style apps only supports the loading of assemblies that are packaged with the app directly.", that I'll be only able to use AssamblyCatalog to load extensions out of a metro style app?

 

Thanks,

Jan

Mar 15, 2012 at 4:13 PM

Hi Jan,

It seems there is a significant regression in the ApplicationCatalog class that we missed. AssemblyCatalog is indeed the only way to make this work today. Sorry about the hassle - we'll file a bug for this.

Thanks for following up!

Nick

Mar 15, 2012 at 7:41 PM

Hi Nick,

thanks for your answers! I hoped there is a way to do it, but at least I now know it couldn't work :)

Happy developing

Jan