如何从 Metro 应用程序中使用 MEF 加载/导入 dll? [英] How to load/import dll with MEF out of metro app?

查看:21
本文介绍了如何从 Metro 应用程序中使用 MEF 加载/导入 dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 MEF 编写可扩展的 Metro 应用程序.我让它与本地扩展一起工作(在当前程序集中).现在我想加载一个外部 dll.DirectoryCatalog 似乎不存在于 .net 4.5 中.因此,我尝试使用 ApplicationCatalog,但在调用 SatisfyImportsOnce 时出现以下错误:Assembly.LoadFrom 在 AppX 中不受支持..

I've trying to write a extendable metro app using MEF. I got it working with a local extension (inside of the current assembly). Now I want to load a external dll. The DirectoryCatalog seems to be not present in .net 4.5. So I tried to use ApplicationCatalog but I got the following error while calling 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);

任何建议出了什么问题?

Any suggestions what's going wrong?

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

I've placed the dll in the Appx directory and run VS11 Beta as administrator.

推荐答案

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

I talked to some supporter in the MEF forums and he confirms that ApplicationCatalog could not be used out of a metro app. So this question is not solveable but could be closed. Source Thread

这篇关于如何从 Metro 应用程序中使用 MEF 加载/导入 dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆