2011-09-22 62 views
0

因此,我有用元数据属性装饰的导出,但在容器上它看起来像这些零件的元数据集合是空的,因此不能正确导入具有元数据的Lazy集合。MEF不导入元数据

任何思考为什么发生这种情况?

+0

我们可以看到一些示例代码? –

+0

我同意这个问题没有足够的上下文来尝试回答。 –

+0

在棱镜,当我在壳限定ImportMany我必须调用容器的方法ComposeParts以便填充集合。我希望这种行为不是针对我解​​决的每个实例。我希望解析后的值在导入时自动生成。 –

回答

0

确保您配置组件的MEF你的引导程序里面探查:

protected override void ConfigureAggregateCatalog() 
     { 
      base.ConfigureAggregateCatalog(); 

      // Need to add self explicitly, otherwise MEF won't know exports we have here 
      this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly())); 

      // Also adding Model project - this is some project that you reference but not Module 
      this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Model.ModelService).Assembly)); 
     }