我正在尝试按照一些入门指南在 .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/