如何使用MEF从Metro应用程序加载/导入DLL? [英] How to load/import dll with MEF out of metro app?
问题描述
我正在尝试使用MEF编写可扩展的Metro应用程序.我将其与本地扩展一起使用(在当前程序集中).现在,我想加载一个外部dll. DirectoryCatalog
似乎在.net 4.5中不存在.因此,我尝试使用ApplicationCatalog
,但是在调用SatisfyImportsOnce
时出现以下错误:Assembly.LoadFrom is not supported in 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);
有什么建议吗?
我已将dll放置在Appx目录中,并以管理员身份运行VS11 Beta.
I've placed the dll in the Appx directory and run VS11 Beta as administrator.
推荐答案
我在MEF论坛上与一些支持者进行了交谈,他确认不能在Metro应用程序之外使用ApplicationCatalog.因此,这个问题无法解决,但可以解决. 源线程
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
这篇关于如何使用MEF从Metro应用程序加载/导入DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!