Reputation: 986
It was a hard journey, basically I have an interface that exports services when the application starts.
[InheritedExport(typeof(IIndusService))]
public interface IIndusService{}
/// <summary>
/// The collection of all indus services created.
/// </summary>
[Export]
public class IndusServicesCollection
{
[ImportMany]
public IEnumerable<IIndusService> IndusServices;
}
One of the service was not exported due to a composition issue. But MEF never trown an exception and silently continued. I managed to track it down by debugging with all exception flags on. The IndusServicesCollection is correctly exported but misses the one service that fails in its ImportingConstructor.
What would be the best way to effectivelly fail or at least retrieve the expection from the GetExportedPart call ?
.NETFramework\v4.8\System.ComponentModel.Composition.xml
(Stacktrace below)
[Native Transition]
RuntimeConstructorInfo.InternalInvoke()
RuntimeConstructorInfo.DoInvoke()
RuntimeConstructorInfo.Invoke()
ConstructorInfo.Invoke()
ReflectionInvoke.SafeInvoke()
ReflectionComposablePart.CreateInstance()
ReflectionComposablePart.GetInstanceActivatingIfNeeded()
ReflectionComposablePart.NotifyImportSatisfied()
ReflectionComposablePart.Activate()
ImportEngine.PartManager.TryOnComposed()
ImportEngine.TrySatisfyImportsStateMachine() [2]
ImportEngine.TrySatisfyImports() [2]
ImportEngine.SatisfyImports() [2]
CompositionServices.GetExportedValueFromComposedPart() [2]
CatalogExportProvider.GetExportedValue() [2]
CatalogExportProvider.CatalogExport.GetExportedValueCore() [2]
Export.get_Value() [2]
ImportingItem.Cast()
ImportingItem.CastSingleExportToImportType()
ImportingItem.CastExportsToCollectionImportType()
ImportingItem.CastExportsToImportType()
ReflectionComposablePart.SetImport()
ReflectionComposablePart.SetImport()
ImportEngine.PartManager.TrySetImport()
ImportEngine.TrySatisfyImportSubset()
ImportEngine.TrySatisfyImportsStateMachine() [1]
ImportEngine.TrySatisfyImports() [1]
ImportEngine.SatisfyImports() [1]
CompositionServices.GetExportedValueFromComposedPart() [1]
CatalogExportProvider.GetExportedValue() [1]
CatalogExportProvider.CatalogExport.GetExportedValueCore() [1]
Export.get_Value() [1]
ExportServices.GetCastedExportedValue<IndusServicesCollection>()
ExportProvider.GetExportedValueCore<IndusServicesCollection>()
ExportProvider.GetExportedValue<IndusServicesCollection>()
ExportProvider.GetExportedValue<IndusServicesCollection>()
Upvotes: 0
Views: 16