MEF - DirectoryCatalog不编写零件 [英] MEF - DirectoryCatalog Not Composing Parts

查看:98
本文介绍了MEF - DirectoryCatalog不编写零件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var asmCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

var commandsDirectory = new DirectoryCatalog(@"..\..\Commands\", "*.cs");

var container = new CompositionContainer(asmCatalog);
container.ComposeParts(this);




提前感谢您的帮助。上面的代码将在使用asmCatalog var时组合部件。切换到commandsDirectory var将加载文件,但不会组成部分。  如果asmCatalog
没有组成部件或者即使文件加载失败,我也希望我的管道是错误的。当然我错过了一些简单的事情。


Thank you for your help in advance. The code above will Compose parts just fine when using the asmCatalog var. Switching to the commandsDirectory var will load the files, but will not compose the parts.  I would expect my plumbing to be wrong if the asmCatalog did not compose the parts or even if the files failed to load. Surely I've missed something simple.

推荐答案

你实际上需要汇编dll而不是cs代码。从您的代码看,您似乎正在尝试直接使用cs文件。
You would actually be needing assembly dll and not cs code. From your code it seems you are trying to directly use cs file.


这篇关于MEF - DirectoryCatalog不编写零件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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