Click here to Skip to main content
15,888,064 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:

C#
[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:

C#
[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:

C#
[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
Posted
Updated 21-Apr-13 21:52pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900