Jan 6, 2012 at 1:14 PM
Edited Jan 6, 2012 at 1:16 PM
maybe someone can give me some hints - I've got a really strange behaviour with MEF.
Unfortunately I can't really post sourcecode, because currently 9 Assemblies are involved and propably I'm not able
to reproduce this with a really small project. That means that the problem will be propably somewhere at my end, but
I really hope that you have some ideas for me.
I'm injecting some Objects through the constructor of a viewmodel. This works very well.
Trying to have the same objects injected by Property or Field does not work. They remain "Null".
Sample in VB
Private _userService As IUserService
Private Sub New(eventAgg As IEventAggregator, us As IUserService)
us does contain a Reference to my UserSerivce, while _userService is Null.
Any Ideas how this might be?
Edit: Even if I delete the serivice from the constructor, it does not work. To have both doesn't make sense, of course. But I know that I will have Constructors with Parameters not known by MEF so in this cases I have to use Property/Field-Injection.
Problem solved. A really good hint for any developer is:
DONT SET A BREAKPOINT WITHIN CONSTRUCTOR AND TRY TO CHECK PROPERTY-INJECTIONS.
It does not work, because they will be injected after execution of the constructor. :)
Thanks Rob for this answer in : http://caliburnmicro.codeplex.com/discussions/244649