Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:26:35+00:00 2026-05-30T09:26:35+00:00

I am starting a project in ASP.NET MVC using Ninject to implement dependency injection.

  • 0

I am starting a project in ASP.NET MVC using Ninject to implement dependency injection. Here is my current architecture:

Abstract Repositories

public interface IAccountRepository<T> where T : class
{
    IQueryable<T> Retrieve();
    T RetrieveByID(int id);
    T RetrieveByEmail(string name);

    bool Create(T entity);
    bool Update(T entity);
    bool Delete(T entity);
}

public interface IRepository<T> where T : class
{
    IQueryable<T> Retrieve();
    T RetrieveByID(int id);
    T RetrieveByName(string name);

    bool Create(T entity);
    bool Update(T entity);
    bool Delete(T entity);
}

Concrete Repositories

public class UserRepository : IAccountRepository<User>
{
    // implementation omitted
}

public class ComicBookIssuesRepository 
    : IRepository<ComicBookIssue>
{
    // implementation omitted
}

Controllers

public class AccountController : Controller
{
    private IAccountRepository<User> userRepository;

    public AccountController(
        IAccountRepository<User> repository)
    {
        this.userRepository = repository;
    }
}

public class ComicBookIssueController : Controller
{
    private IRepository<ComicBookIssue> issueRepository;

    public ComicBookIssueController(
        IRepository<ComicBookIssue> repository)
    {
        this.issueRepository = repository;
    }    
}

Dependency Injection

public class NinjectControllerFactory 
    : DefaultControllerFactory
{
    private IKernel ninjectKernel;

    public NinjectControllerFactory()
    {
        ninjectKernel = new StandardKernel();
        AddBindings();
    }

    protected override IController GetControllerInstance(
        RequestContext requestContext, Type controllerType)
    {
        return controllerType == null ? null : 
            (IController)ninjectKernel.Get(controllerType);
    }

    private void AddBindings()
    {
        ninjectKernel.Bind<IRepository<ComicBookIssue>>()
            .To<ComicBookIssuesRepository>();
        ninjectKernel.Bind<IAccountRepository<User>>()
            .To<UserRepository>();
    }
}

The binding of IRepository<ComicBookIssue> to ComicBookIssuesRepository works fine, as it is able to construct and inject the ComicBookIssueController with no errors. However, when trying to inject into the AccountController, it throws the following error:

Error activating IAccountRepository{User} No matching bindings are
available, and the type is not self-bindable. Activation path:
2)
Injection of dependency IAccountRepository{User} into parameter
repository of constructor of type AccountController
1) Request for
AccountController

Suggestions:
1) Ensure that you have defined a binding for
IAccountRepository{User}.
2) If the binding was defined in a module,
ensure that the module has been loaded into the kernel.
3) Ensure
you have not accidentally created more than one kernel.
4) If you are
using constructor arguments, ensure that the parameter name matches
the constructors parameter name.
5) If you are using automatic module
loading, ensure the search path and filters are correct.

I can’t figure out what is causing the error for one dependency and not the other. The two follow the same pattern, just implement different interfaces. Has any one else experienced this error or can find a problem with my implementation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:26:37+00:00Added an answer on May 30, 2026 at 9:26 am

    In the comments on my original post, Remo was correct about conflicting code. There was a conflicting version of the User model class left in my project that I forgot to remove. The controller was referencing this class, while Ninject was binding to the other version. Removing the old version solved the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting an ASP.NET MVC project using SubSonic 3 ActiveRecord. I added a table
I'm starting a project that will be public facing using asp.net mvc. I know
I am starting out on a project that will involve ASP.NET MVC using a
I'm just starting my first project in ASP.NET MVC. In my webforms experience, I
I am starting a new ASP.Net MVC project and was wondering what is the
All, I'm starting a new ASP.NET MVC project which requires some content management capabilities.
I am a beginner in ASP.Net. I am starting a new project using ASP.Net
Currently in the early stages of developing a very large project using ASP.Net MVC.
Consider an ASP.NET MVC 1.0 project using the Areas convention as described on this
We are starting up a new project in ASP.Net MVC, could you please suggest

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.