How to manually instantiate objects using Ninject for MVC 3

asp.net-mvc-3, ninject.web.mvc

Solution

It is better to inject dependencies instead of resolving them. Service Locator is an anti-pattern. You could for example use the following:

IMyService myService = DependencyResolver.Current.GetService<IMyService>();

But please do not use it. That's an anti-pattern.

Dependency injection is the preferred way. You should have the constructor of the class that needs this dependency take an `IMyService` instead of having the class fetch this dependency.

Problem

How is it possible to use Ninject inside ASP.NET MVC 3 to instantiate objects manually? Something as ``` "NinjectObject".Resolve<IMyService>(); ``` Thank you & regards

Original source