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

  • Home
  • SEARCH
  • 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 8940267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:59:50+00:00 2026-06-15T10:59:50+00:00

I have a ASP.NET MVC application and I’m using MEF to import my interfaces.

  • 0

I have a ASP.NET MVC application and I’m using MEF to import my interfaces. The problem is that my IVotesRepository interface is null when it’s passed to the constructor.

Here is the code from my controller:

public class VotesController : BaseController
{
    //
    // GET: /Votes/
    IVotesRepository VotesRepository;
    IAccountRepository accountRepository;

    public VotesController(IVotesRepository votesRepo, IAccountRepository accountRepo)
    {
        VotesRepository = votesRepo;
        accountRepository = accountRepo;
    }

And here is the interface and the repository itself:

public interface IVotesRepository
{
    void SaveVotes(int TeamId, int GameId, int UserId);

    bool CheckIfUserHaveVoted(int UserId, int GameId);
}

[Export(typeof(IVotesRepository))]
public class VotesRepository : IVotesRepository
{
   ...
}

Why is the IVotesRepository instance null?

EDIT:

Stack trace:

Object reference not set to an instance of an object at SocialSport.Controllers.VotesController.SaveVotes(Nullable`1 TeamId, Nullable`1 GameId) in C:\...\Visual Studio 2010\Projects\SocialSport\Implementation\Source\SocialSportWeb\Controllers\VotesController.cs:line 29
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
  • 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-06-15T10:59:51+00:00Added an answer on June 15, 2026 at 10:59 am

    it seems that somewhere in my app I’ve unregistered that interface somehow, so I’ve made another interface and now it’s working, sorry if it’s a dirty fix, but I didn’t had the time to make the proper corrections, thanks for your help.

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

Sidebar

Related Questions

I have ASP.NET MVC application that has list with jQuery Selectable list. My problem
I have an Asp.Net MVC application using Forms Authentication that is published to the
I have an ASP.NET MVC application that uses Fluent NHibernate and AutoMapper. I am
I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This
I have an Asp.Net MVC application that works in the vs.net development web server.
I have a ASP.NET MVC application using NHibernate and the application runs fine when
I have a ASP.NET MVC application that runs in both IIS 6 and 7.
I have an ASP.Net MVC application and I'm using Forms authentication in SQL Server.
We have an asp.net mvc application that we would like to integrate a FileSystemWatcher
I have an ASP.Net MVC application that uses SQL Server 2005 via NHibernate. I

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.