1
Vote

GenericCatalog CreateDynamicExport returing null is some cases

description

If the importDefinition passed to CreateDynamicExport is a non generic interface the return value could be null. This should never happen or the program will crash.
 
Using reflector on CatalogExportProvider::GetExportsCore you will see why.
 
foreach (Tuple<ComposablePartDefinition, ExportDefinition> tuple in valueAllowNull.GetExports(definition))
 
I see two solutions: set the export before the return value if it is null or change:
 
if (importDefinitionType.IsClass)
to
if (importDefinitionType.IsClass || importDefinitionType.IsInterface)
 
I don't know if that change is correct but for now it seems to work around my issue.
 
Mike

comments