我有folllowing:問題與MEF
private void ConfigureMEFContainer()
{
_catalog = new DirectoryCatalog(_pluginsPath);
_container = new CompositionContainer(_catalog);
}
private readonly string _pluginsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
private DirectoryCatalog _catalog;
private CompositionContainer _container;
容器傳遞到另一個類:以上
var batch = new CompositionBatch();
batch.AddPart(this);
container.Compose(batch);
[ImportMany(typeof(IOnAnnotationCreatedPlugin))]
public Lazy<IOnAnnotationCreatedPlugin, IAnnotationPluginMetadata>[] OnCreatedPlugins { get; set; }
[ImportMany(typeof(IOnAnnotationCreatingPlugin))]
public Lazy<IOnAnnotationCreatingPlugin, IAnnotationPluginMetadata>[] OnCreatingPlugins { get; set; }
[ImportMany(typeof(IOnAnnotationUpdatedPlugin))]
public Lazy<IOnAnnotationUpdatedPlugin, IAnnotationPluginMetadata>[] OnUpdatedPlugins { get; set; }
[ImportMany(typeof(IOnAnnotationUpdatingPlugin))]
public Lazy<IOnAnnotationUpdatingPlugin, IAnnotationPluginMetadata>[] OnUpdatingPlugins { get; set; }
所有的集合是空的!
任何幫助?
您好,感謝您的回覆。我調試了目錄,並且能夠看到在「插件」文件夾中找到的唯一程序集。似乎問題在於自己編寫的出口/進口不匹配。有任何想法嗎? – Bill 2011-01-27 07:33:14
@bhaidar出口可能與進口不匹配的原因很多。他們列在我鏈接的博客文章中。 – 2011-01-27 20:07:59