1
votes

I just added Ninject dependency injection into my code, and after righting the constructor I am getting the following error on my Constructor:

Inconsistent accessibility: parameter type 'Final.Models.IUserRepo' is less accessible than method 'Final.Controllers.HomeController.HomeController(Final.Models.IUserRepo)'    C:\Users\Ali\Documents\Final\Final\Controllers\HomeController.cs    17  16  Final

Following is my HomeController

public class HomeController : Controller
{
    IUserRepo repo;

    public HomeController(IUserRepo u)
    {
        u = repo;
    }
}

Here is my interface:

namespace Final.Models
{
    interface IUserRepo
    {
        void save(User u);
    }
}

I tried changing all the methods to public but nothing worked.

1
I have edited your question down to an MCVE, as your question didn't follow the Minimal principle. Please keep that in mind for future questions. - mason
I assume you mean repo = u, not u = repo; - user3559349

1 Answers

2
votes

Make it a public interface. That's what the error message is telling you. You can't use it as a parameter on a public method (the constructor) if the interface is private. Otherwise, how could one construct a HomeController?

namespace Final.Models
{
    public interface IUserRepo
    {
        void save(User u);
    }
}

Also, you should modify your code to follow standard C# naming conventions. Don't use abbreviation, PascalCase your method names.

namespace Final.Models
{
    public interface IUserRepo
    {
        void Save(User uuser);
    }
}