MEF不导入元数据

时间:2011-09-22 20:01:18

标签: prism mef

因此,我有使用元数据属性修饰的导出,但在容器上,这些部分的元数据集合似乎是空的,因此无法正确导入带元数据的Lazy集合。

有没有想过为什么会这样?

1 个答案:

答案 0 :(得分:0)

确保为MEF配置程序集以在Bootstrapper中进行探测:

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));
        }