How to resolve error :the type does not appear to implement microsoft.practices.servicelocation.iservicelocator?

One year after, I encountred the same problem... Thanks to pdb's answer, I could find a work-around. Forcing System.Web.Mvc.IDependencyResolver instead of System.Web.Http.Dependencies.IDependencyResolver in the customized NinjectDependencyResolver caused cast problems in cases other parts of code need the System.Web.Http.Dependencies.IDependencyResolver. For example when you try to generalize the customized DI :

GlobalConfiguration.Configuration.DependencyResolver =
    new NinjectDependencyResolver(kernel)

In my case, I implemented the both IDependencyResolver and it worked like this :

public class NinjectDependencyResolver
    : NinjectDependencyScope
    , IDependencyResolver
    , System.Web.Mvc.IDependencyResolver

The problem is that your NinjectDependencyResolver doesn't implement the IDependencyResolver interface, but inherits from the DependencyResolver class. The DependencyResolver does not implement IDependencyResolver and this causes your own methods to be unrelated to anything MVC knows.

Just change to:

public class NinjectDependencyResolver : IDependencyResolver

But as Ufuk Hacıoğulları says, you can use the official Ninject.MVC3 NuGet package to integrate Ninject with MVC. This package is created by the developers of Ninject and depends on the Ninject core library.


I made a similar mistake at the same point. I had implemented IDependencyResolver and got the identical error. It was caused by the wrong 'using' statement - there is a similar IDependencyResolver in System.Web.Http. Check you are using System.Web.Mvc.