Quantcast
Channel: Managed Extensibility Framework
Viewing all articles
Browse latest Browse all 265

New Post: ComposeParts Exception due Multitple Metadata entries

$
0
0
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

Sam
[ImportMany]
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.

Thanks

Viewing all articles
Browse latest Browse all 265

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>