Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

How do I configure Ninject so it injects an instance in a view model?

PS. It is an abstracted service to help with validation, so I am not trying to burden the model with too much responsibilities.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Refer to this SO question - http://stackoverflow.com/questions/8176654/di-ninject-working-for-controllers-but-not-view-model, which points to this link - http://bradwilson.typepad.com/blog/2010/10/service-location-pt5-idependencyresolver.html.

I also had the same issue. For that I extended my NinjectControllerFactory class to provide me with an instance of the required dependency. I blogged about this here - http://blog.thekfactor.info/posts/dependency-injection/.

I may have to look in to the link from the SO post too and see if that's a better alternative.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.