Unexpected DirectoryCatalog Behaviour With Preview 5

Apr 24, 2009 at 9:39 PM
Hi Guys,

I have just updated my project to use preview 5

The following code was working using preview 4

catalog = new AggregateCatalog();
foreach(String dir in Directory.GetDirectories(Path.Combine(_unpackedPath, "Slides"), "*", SearchOption.TopDirectoryOnly)) {
new DirectoryCatalog(dir));
var container = new CompositionContainer(catalog);
Collection<IBaseSlide> tmpSlides = container.GetExportedObjects<IBaseSlide>();

The collection of exported objects remains at zero where using preview 4 the collection was populated

The only difference I can see is that the class this code is in now has

where in preview 4 it was
[CompositionOptions(CreationPolicy = CreationPolicy.NonShared)]

Thanks in advance



Apr 24, 2009 at 10:27 PM
Found it!!!!

You have introduced a default searchPattern on the constructor of the the DirectoryCatalog (*.dll)

My classes are inside an exe so changing the line to

catalog.Catalogs.Add(new DirectoryCatalog(dir, "*.exe"));

Fixes it.