Попытка выполнить импорт в коде, поэтому я пытаюсь это:
IServiceBehavior behavior = container.GetExport<IServiceBehavior>().Value;
, но получаю это исключение:
{"No valid exports were found that match the constraint '((exportDefinition.ContractName == \"System.ServiceModel.Description.IServiceBehavior\") AndAlso (exportDefinition.Metadata.ContainsKey(\"ExportTypeIdentity\") AndAlso \"System.ServiceModel.Description.IServiceBehavior\".Equals(exportDefinition.Metadata.get_Item(\"ExportTypeIdentity\"))))', invalid exports may have been rejected."}
Но когда я проверяю локальные элементы для контейнера MefServiceBehavior,реализация IServiceBehavior, есть в каталоге:
container {System.ComponentModel.Composition.Hosting.CompositionContainer} System.ComponentModel.Composition.Hosting.CompositionContainer
- Catalog {MefContrib.Hosting.Generics.GenericCatalog} System.ComponentModel.Composition.Primitives.ComposablePartCatalog {MefContrib.Hosting.Generics.GenericCatalog}
- Parts Count = 6 System.Collections.ObjectModel.ReadOnlyCollection<System.ComponentModel.Composition.Primitives.ComposablePartDefinition>
- [4] {MyProjectServiceLibrary.Hosting.MefServiceBehavior} System.ComponentModel.Composition.Primitives.ComposablePartDefinition {System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePartDefinition}
- ExportDefinitions {System.ComponentModel.Composition.Primitives.ExportDefinition[1]} System.Collections.Generic.IEnumerable<System.ComponentModel.Composition.Primitives.ExportDefinition> {System.ComponentModel.Composition.Primitives.ExportDefinition[]}
- [System.ComponentModel.Composition.Primitives.ExportDefinition[]] {System.ComponentModel.Composition.Primitives.ExportDefinition[1]} System.ComponentModel.Composition.Primitives.ExportDefinition[]
- [0] {MyProjectServiceLibrary.Hosting.MefServiceBehavior (ContractName="System.ServiceModel.Description.IServiceBehavior")} System.ComponentModel.Composition.Primitives.ExportDefinition {System.ComponentModel.Composition.ReflectionModel.ReflectionMemberExportDefinition}
- [System.ComponentModel.Composition.ReflectionModel.ReflectionMemberExportDefinition] {MyProjectServiceLibrary.Hosting.MefServiceBehavior (ContractName="System.ServiceModel.Description.IServiceBehavior")} System.ComponentModel.Composition.ReflectionModel.ReflectionMemberExportDefinition
- Metadata Count = 1 System.Collections.Generic.IDictionary<string,object> {Microsoft.Internal.Collections.ReadOnlyDictionary<string,object>}
- [0] {[ExportTypeIdentity, System.ServiceModel.Description.IServiceBehavior]} System.Collections.Generic.KeyValuePair<string,object>
Key "ExportTypeIdentity" string
Value "System.ServiceModel.Description.IServiceBehavior" object {string}
Почему контейнер не находит экспорт.ExportTypeIdentity совпадает с указанным в сообщении об исключении.Что здесь происходит?