This project has moved. For the latest updates, please go here.


Jul 22, 2010 at 12:31 PM
Edited Jul 23, 2010 at 11:05 AM


I am using the following code to add different DLLs from the plugin folder into my app.

A checkbox changes the boolean 'filter' and causes a call to 'reloadStuff()' The filter causes (as you may see) that only some of the parts will be in the filtered catalog.

It works fine when adding 'this' to the batch, but without it, the import object is null. How can that be?

Thanks in advance.


private void Form1_Load(object sender, EventArgs e) {


catalog = new DirectoryCatalog("plugins");

catalog.Changed += catalog_Changed;



private bool reloadStuff() {


CompositionBatch batch = new CompositionBatch();

CompositionContainer container;

if (filter) {

var filteredCat = new FilteredCatalog(catalog, def => def.Metadata.ContainsKey("type") && def.Metadata["typ"].ToString() == "animals");

container = new CompositionContainer(filteredCat);


} else {

container = new CompositionContainer(catalog);


} try {

batch.AddPart(this); //WHY is it not working, when this line is removed?


} catch (Exception g) {

MessageBox.Show("No DLLs " + g.Message);


return true;



public class FilteredCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged

{ ,,, }

Jul 22, 2010 at 12:35 PM
Edited Jul 23, 2010 at 11:06 AM

seems newline is ignored??


well at least yesterday - now that is some mysteria...

Jul 22, 2010 at 7:10 PM

Edit your post to fix the new lines. It will make it much easier to understand your problem. I'm frankly a bit scared by that big chunks of text.

Jul 23, 2010 at 1:34 PM

I hope now its easy to help =)