我试图使用 MEF 编写一个可扩展的 Metro 应用程序。我让它与本地扩展一起工作(在当前程序集内部)。现在我想加载一个外部dll。这 DirectoryCatalog .net 4.5 中似乎不存在。所以我尝试使用 ApplicationCatalog 但我在调用时遇到以下错误 SatisfyImportsOnce: Assembly.LoadFrom is not supported in AppX..

这是我的代码:

var catalog = new AssemblyCatalog(GetType().GetTypeInfo().Assembly);
ApplicationCatalog catApp = new ApplicationCatalog();
AggregateCatalog cat = new AggregateCatalog(catalog, catApp);
_compositionService = cat.CreateCompositionService();
_compositionService.SatisfyImportsOnce(this);

有什么建议吗?出了什么问题?

我已将 dll 放在 Appx 目录中并以管理员身份运行 VS11 Beta。

有帮助吗?

解决方案 2

我与 MEF 论坛中的一些支持者进行了交谈,他确认 ApplicationCatalog 无法在 Metro 应用程序中使用。所以这个问题无法解决,但可以关闭。源线程

其他提示

您的外部库超出了 Metro 允许的沙箱范围。Metro环境中的.NET框架是有限的,类似于WP7或Micro Framework。有很多东西被砍掉了。如果您的外部 DLL 不是使用这些受限库构建的,那么编译器将不允许使用它。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top