Hi@all!
I have a service, which uses user defined object providers (e.g. logic to access different data sources) by [ImportMany]. Since I want to use the default PRISM ILoggerFacade within the IObjectProvider Implementations, I have set up the importing constructor like this:
[Export(typeof(IObjectProvider))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class SomeProviderImplementation: IObjectProvider
{
private ILoggerFacade _logger;
[ImportingConstructorAttribute]
public SomeProviderImplementation(ILoggerFacade logger)
{
this._logger = logger;
}
}
Those IObjectProvider implementations are used within an implementation of ISomeService:
[Export(typeof(ISomeService))]
[PartCreationPolicy(CreationPolicy.Shared)]
public class SomeService: ISomeService, IDisposable
{
private ILoggerFacade _logger;
[ImportMany(typeof(IObjectProvider))]
private List<IObjectProvider> _knownProviders { get; set; }
[ImportingConstructor]
public SomeService(ILoggerFacade logger)
{
this._logger = logger;
}
[...]
}
Within a module, I reference 'ISomeService' by [Import] as well:
[ModuleExport("SomeModule", typeof(SomeModule), InitializationMode = InitializationMode.WhenAvailable)]
public class SomeModule: IModule
{
[Import(typeof(ISomeService))]
public ISomeService_service { get; private set; }
[...]
}
When I run this, I get a CompositionException -->
No valid exports were found that match the constraint
ContractName Microsoft.Practices.Prism.Logging.ILoggerFacade
RequiredTypeIdentity Microsoft.Practices.Prism.Logging.ILoggerFacade
Within my SomeService Implementation the ILoggerFacade is provided and useable, but the IObjectProvider do not get it. Any idea what's wrong in there?
Thanks a lot in advance
Rowan