c# - MEF:缺少 ComposeParts

标签 c# .net mef

我正在尝试按照一些入门指南在 .Net 4 中使用 MEF,但在设置应用程序时遇到了困难。说明说要这样做:

var catalog = new DirectoryCatalog(@".\");
var container = new CompositionContainer(catalog);
container.Composeparts(this);

但是 .Net 4 中包含的 System.ComponentModel.Composition 版本似乎没有在 CompositionContainer 上可用的 Composeparts 方法,我无法找到关于如何在当前系统中执行此操作的良好引用。

这是我目前使用的引用资料: Building Composable Apps in .NET 4 with the Managed Extensibility Framework

有没有人有更好的引用资料值得我引用?

最佳答案

CompositionContainer 确实有一个 ComposeParts 方法,作为 extension method .

参见 this一些工作代码的引用。

关于c# - MEF:缺少 ComposeParts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3267937/

相关文章:

c# - 如何抑制整个命名空间文件的 StyleCop 警告

c# - Task.Delay 在等待时会浪费系统资源吗?

c# - 用于从动态创建的文本框(用 Javascript)捕获数据的 ASP.NET 代码可能是什么样的?

mef - Caliburn Micro:基于MEF的方案的插件相关问题

c# - 在 MEF 中解析 HttpRequestBase

c# - 这个 Singleton 实现是否正确且线程安全?

c# - 在 .NET 中,我可以检测系统焦点事件 (C#) 吗?

c# - 如何在查询完成之前按顺序开始处理并行查询的结果?

javascript - 在手机上点击 'Go' 时停止表单提交

c# - 可扩展的 ASP.NET MVC Web 应用程序