Problem with ExportProvider

May 17, 2010 at 12:03 PM

Hi everybody!
I'm creating a custom ExportProvider in order to manage exception thrown by plugins' constructor

This's the code and I'm using it in the following way

_pluginExportProvider = new PluginExportProvider(_directoryCatalog);
//_compositionContainer = new CompositionContainer(_aggregateCatalog, _pluginExportProvider);
_compositionContainer = new CompositionContainer(_pluginExportProvider);

But when I try to get plugins I get this exception's message

Cannot cast the underlying exported value of type 'PIT.Plugins.Plugin3 (ContractName="TD.Moongose.Plugins.Interfaces.IPlugin")' to type 'TD.Moongose.Plugins.Interfaces.IPlugin'.

If I remove the PluginExportProvider I don't get any expcetion and everything works correctly...

Any idea??


May 18, 2010 at 6:24 PM

Review "TryGetExportsCore" method of MEF ExportProvider.

Although, the ExportProvider.GetExports already calling TryGetExportsCore internally.