I have a MEF composition question. In my development environment I am able to use this code to import parts.
var dirCatalog = new DirectoryCatalog(path, "MyCompany.*.dll");
var container = new CompositionContainer(dirCatalog);
container.SatisfyImportsOnce(this);
However when I deploy to a test server that doesn't work. The only way I have found to make it work right is to explicitly load the the dlls that have exports like this:
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(Path.Combine(path, "MyCompany.Services.AppServer.Modelling.dll"))));
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(Path.Combine(path, "MyCompany.IFS.AppServer.Dispatchers.dll"))));
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(Path.Combine(path, "MyCompany.Services.AppServer.Service.dll"))));
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(Path.Combine(path, "MyCompany.IFS.Common.InstrumentService.Proxy.dll"))));
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(Path.Combine(path, "MyCompany.IFS.Common.InstrumentPropertyService.Proxy.dll"))));
var container = new CompositionContainer(catalog);
container.SatisfyImportsOnce(this);
Obviously, I don't really want to explicitly load every dll that has an export in it; that sort of defeats the purpose of MEF. But, right now that's the only thing I have found that works.
This code is in a custom service host factory used for starting a WCF service hosted in IIS. Not sure that that matters...
TIA, Greg