I have MEF/Prism 4 project for which I can resolve imports via the ImportingConstructor, but not via field imports in the same class.
In the sample code below, myDataService
is correctly resolved in the constructor. But _myDataServiceFieldImport
isn't resolved, despite the Import
attribute. Same result whether it's a field or property.
Anything obvious I'm missing here?
[ModuleExport(typeof(TestModule))]
public class TestModule : IModule
{
private IMyDataService _myDataService;
[Import]
private IMyDataService _myDataServiceFieldImport;
[ImportingConstructor]
public TestModule(IMyDataService myDataService)
{
_myDataService = myDataService;
}
}
[PartCreationPolicy(CreationPolicy.Shared)]
[Export(typeof(IMyDataService))]
public class MyDataService : IMyDataService
{
}