CompositionBatch

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

Hi,

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.

Jens

private void Form1_Load(object sender, EventArgs e) {

output.Items.Add("loaded");

catalog = new DirectoryCatalog("plugins");

catalog.Changed += catalog_Changed;

reloadStuff();

}

private bool reloadStuff() {

catalog.Refresh();

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);

batch.AddPart(filteredCat);

} else {

container = new CompositionContainer(catalog);

batch.AddPart(catalog);

} try {

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

container.Compose(batch);

} catch (Exception g) {

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

}

return true;

}

 

public class FilteredCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged

{ ,,, }

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

seems newline is ignored??

 

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

Jul 22, 2010 at 8: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 2:34 PM

I hope now its easy to help =)