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

ComposeParts Exception due Multitple Metadata entries

Apr 16, 2013 at 5:05 PM
Edited Apr 16, 2013 at 5:06 PM
Dear All

My application uses DirectoryCatalog to import parts from third party dlls. The problem I have have is, ComposeParts fails to load every other when a single plugin developer decorates their exports with multiple metadata entries but fails to set IsMultiple attribute to true. This is something I have no control over.

My question is: is there a way I can configure my code so that that invalid metadata attributes like will not cause failure to load all other plugins in the folder?
OR can I instruct CompositionContainer to ignore exports with this problem?

Thanks in advance

private IEnumerable<Lazy<object, TDic>> item;

[Export(typeof(System.Func<string, object[], object>))]
[ExportMetadata("Name", "Name 1")]
[ExportMetadata("Name", "Name 2")]
public object Subtract(string f, object[] args) {
   return "Evaluate Subtract";

[Export(typeof(System.Func<string, object[], object>))]
[ExportMetadata("Name", "Name 1")]
[ExportMetadata("Address", "Address 1")]
public object Add(string f, object[] args) {
   return "Evaluate Add";
Both Subtract and Add resides in user's class. I want to be able to import 'Add' and ignore 'Subtract' because of the error due to multiple metadata entry without 'IsMultiple' flag being set. Any ideas on what I am doing wrong will be most welcome.