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 8441859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:40:58+00:00 2026-06-10T08:40:58+00:00

I have a web application that uses .NET Framework 4, MVC 4, Ninject 3.

  • 0

I have a web application that uses .NET Framework 4, MVC 4, Ninject 3. Originally I was using .NET Framework 4.5 but I changed the “Target Framework” to 4.0 and fixed all the errors it caused. Now the application runs perfectly on my local box. The problem is that when I deploy it to Azure I get the server error at the bottom of this post.

I have seen this error before. When I was first starting to use Ninject I would get this error when I wasn’t binding correctly in the Global.asax (relevant code below).

Also, my Ninject.dll reference “Copy Local” property is set to “True”.

What am I doing wrong? Why am I getting this error when I try to view the web application in Azure but not on my local box?

Thank you for your help,

Aaron

HomeController.cs:

public class HomeController : Controller
{
    IAuthorizationService _authorizationService;
    IUserService _userService;

    public HomeController(IAuthorizationService authorizationService, IUserService userService)
    {
        _authorizationService = authorizationService;
        _userService = userService;
    }
}

Global.asax:

protected void Application_Start()
{
    SetupDependencyInjection();
}

private void SetupDependencyInjection()
{
    //create Ninject DI Kernel
    IKernel kernel = new StandardKernel();

    //register services with Ninject DI container
    RegisterServices(kernel);

    //tell asp.net mvc to use our Ninject DI Container
    DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
}

private void RegisterServices(IKernel kernel)
{
    kernel.Bind<IAccountService>().To<AccountService>().WithConstructorArgument("connectionString", ConfigurationManager.ConnectionStrings["AccountManagerEntities"].ConnectionString);
}

Server Error:

No parameterless constructor defined for this object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[MissingMethodException: No parameterless constructor defined for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +106
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +84

[InvalidOperationException: An error occurred when trying to create a controller of type 'AccountManager.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +85
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +280
   System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +66
   System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +19
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +161
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +405
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
  • 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-10T08:41:00+00:00Added an answer on June 10, 2026 at 8:41 am

    Sandrino Di Mattia, you are correct, I need to register the other interfaces. Actually, I do have them registered. For the sake of being to-the-point in my example code I cut out portions that were relevant. :p

    The way I fixed it was merely uninstalling Ninject with NuGet and then re-installing it with NuGet. I had read an article on the internet that said that I’d have to do this with Entity Framework to allow it to install properly with .NET 4.0 after re-targeting from 4.5. So, when that solved my EF problems I tried it with Ninject and it worked.

    So, the moral of all this is when re-targeting from .NET 4.5 to .NET 4.0, uninstall your NuGet packages and then re-install them.

    Aaron

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

Sidebar

Related Questions

I have built an ASP.NET MVC web application that uses Entity Framework. To provide
I have a simple ASP.NET MVC web application that uses NHibernate with FluentNHibernate's auto
I have a asp.net web application that uses C#. It logs in on a
I have an ASP.NET (v2.0) web application that uses a reference to a SQL
I have a Web Application (ASP.NET C# for .NET 3.5) that uses the Session
I have a web application that uses fixed css width. (1280px). With jquery, I
I have an asp.net application which uses the web part framework to allow users
I have a C# web forms ASP.NET 4.0 web application that uses Routing for
I have a web application that uses the asp.net membership and role providers to
I have a .NET 4.0 web application that uses a .NET 2.0 assembly. I've

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.