How can I use an interface in a main controller of an ASP.NET MVC project?

I am working on ASP.NET MVC project where I have one solution dotnetmvc which contains two projects:

  1. dotnetmvc (main project)
  2. Service (contains an interface for it).

My problem is that when I am trying to use an interface from the Service project within a controller of the main project then I am not getting a reference to the interface.

Please refer to the below screenshots:

Screenshot 1
How can I use an interface in a main controller of an ASP.NET MVC project?

Screenshot 2
How can I use an interface in a main controller of an ASP.NET MVC project?

What am I missing?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I know of 2 reasons why this would happen:

  1. your interface is not public. make sure you add public.
public interface IUser
{
 .......
}
  1. the project dotnetmvc is on a lower dotnet version as the Service project
  • Right click on each project, select properties and make sure dotnet version is the same on both projects


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x