Reputation: 3541
Im currently new to C#, and Im following a book to learn C#. I have the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EssentailToos.Models;
using Ninject;
namespace EssentailToos.Infrastructure
{
public class NinjectDependencyResolver : IDependencyResolver
{
private IKernel kernel;
public NinjectDependencyResolver(IKernel kernelParam)
{
kernel = kernelParam;
AddBindings();
}
public object GetService(Type serviceType)
{
return kernel.TryGet(serviceType);
}
public IEnumerable<object> GetServices(Type serviceType)
{
return kernel.GetAll(serviceType);
}
private void AddBindings()
{
kernel.Bind<IValueCalculator>().To<LinqValueCalculator>();
}
}
}
When I'm trying to run this, I get the error: The type or namespace name 'IDependencyResolver' could not be found
Im new to C#, so can anyone explain why I get this error message?
Upvotes: 0
Views: 2023
Reputation: 1308
You need to add namespace of the IDependencyResolver. Add the following line into the usings
using System.Web.Mvc
Upvotes: 3