Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MEF doesn't import root exe parts

I'm creating composition container using root DirectoryCatalog.

var catalog = new DirectoryCatalog(".");
Bootstrapper.CompositionContainer = new CompositionContainer(catalog, true); 

My executable is "Main.exe" 2 issues:

  1. Main.exe is not a list of probed files, how do I include it in a list?
  2. All other references probed, is there any way to filter list?
like image 341
katit Avatar asked Dec 25 '22 22:12

katit


1 Answers

For the first part of your question you can use the overload which accepts a search filter for files

var catalog = new DirectoryCatalog(".", "My.Company*.dll"); // asemblies to load

To load both *.exe and *.dll do:

 var catalog = new AggregateCatalog();
 catalog.Catalogs.Add(new DirectoryCatalog(".")); // load only *.dll's
 catalog.Catalogs.Add(new DirectoryCatalog(".", "*.exe")); // load *.exe

 Bootstrapper.CompositionContainer = new CompositionContainer(catalog, true); 
like image 76
rene Avatar answered Dec 29 '22 10:12

rene