我有MEF/Prism 4項目,我可以通過ImportingConstructor解析導入,但不能通過同一類中的字段導入。MEF字段導入未解決
在下面的示例代碼中,myDataService
在構造函數中正確解析。但_myDataServiceFieldImport
不解決,儘管Import
屬性。相同的結果,無論它是一個領域或財產。
任何明顯的我在這裏失蹤?
[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
{
}
我剛剛做到了! – sambomartin 2014-07-02 16:04:27