ImportMany == NULL

Topics: Actions & Coroutines, Bootstrappers & IoC, Framework Services, UI Architecture
Aug 9, 2011 at 10:38 PM

[ImportMany(typeof(IParser))]
public IEnumerable<Lazy<IParser, IParserMetaData>> _airlines { get; set; }

So the assembly that contains this is being injected (for the lack of proper terms, about to head to airport),  but the import is never satisfied, what would cause this?  do i just drop the typeof and try with out?  I want a multiple import since there will be many parsers that parse different schedule types over the long run but for now I am only testing with my schedule variant parser.  The 2 that I have setup are attributed with [Export(typeof(IParser))]  what am I missing?

The underlying view is a settings view for selecting the airline said user works for.  I have used MEF before not sure what I am missing at this point.

 

Morgan.

Aug 9, 2011 at 11:30 PM

Could it be a problem of MetaData not matching?

Aug 13, 2011 at 2:59 AM
Edited Aug 13, 2011 at 3:00 AM

I tried to play around with the signature and well, tried the above code in the ShellViewModel and this resulted in the satisfied import.  Having this on the SettingsViewModel does nothing, its almost like the screen never really goes through all my code I had put a few Diagnostic Debugs in place and its like they never were there, they don't ever get hit.  So the turn question now is why is this only working on the ShellViewModel and not the SettingsViewModel.  The settingsview/viewmodel are called via menu click and ActivateItem(new SettingsViewModel()) is used to change the contentcontrol.

What am I missing.

 

Morgan.

Aug 14, 2011 at 5:41 AM

hours later, pulling out my hair :P.  Got it working...  It was a combination of contract / collection initialization.