1
我有出口IScreen
兩班,但是當我輸入相同的使用ImportMany MEF負荷合同的兩倍
[ImportMany(typeof(IScreen))]
private IEnumerable<Lazy<IScreen,IJIMSMetadata>> _modules;
public IEnumerable<Lazy<IScreen, IJIMSMetadata>> Modules
{
get { return _modules; }
}
模塊包含IScreen的四個實例,但我只有兩個出口。
這是集裝箱
container = new CompositionContainer(
new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)))
);
protected override IEnumerable<Assembly> SelectAssemblies()
{
string _modulePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Modules");
var files = Directory.GetFiles(_modulePath, "*.dll", SearchOption.AllDirectories);
List<Assembly> assemblies = new List<Assembly>();
assemblies.Add(Assembly.GetExecutingAssembly());
foreach (var file in files)
{
assemblies.Add(Assembly.LoadFrom(file));
}
return assemblies;
}
告訴我們你是如何構建CompositionContainer中 – m0sa
該集裝箱的貨物使用assemby.load從 –
野生的猜測僅僅是一個類,但位於您裝配的地方在那裏通過它的位置遞歸將加載「同一集結號」的兩倍。例如。它通過'Debug'和'Release'文件夾遞歸? –