Note that there are some explanatory texts on larger screens.

plurals
  1. PONinject.Web.Common and Ninject.Mvc isn't setting the DependencyResolver to use the NinjectDependencyResolver
    primarykey
    data
    text
    <p><strong>UPDATE</strong></p> <p>Starting a Bounty, I have added is a Visual Studio 2010 solution replicating the Ninject bug as this seems to be quite a localised issue.</p> <p><a href="https://dl.dropboxusercontent.com/u/101891564/NinjectTest.zip" rel="nofollow noreferrer">Ninject VS 2010 Solution</a></p> <hr> <p>When I do the following:</p> <ol> <li><p>Start Visual Studio 2010 (yes 2010 :-( ) </p></li> <li><p>File > New Project > Empty MVC 4 Application</p></li> <li><p>Manage Packages > install package Ninject.Web.Common (which then installs Ninject and Ninject.Mvc)</p></li> <li><p>Then do the following in a HomeController </p></li> </ol> <p>Code: </p> <pre><code> public class HomeController : Controller { public HomeController(IKernel kernel) { // Should have been injected } } </code></pre> <p>I get this: </p> <pre><code>Server Error in '/' Application. 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. Stack Trace: [MissingMethodException: No parameterless constructor defined for this object.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +113 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark&amp; stackMark) +232 System.Activator.CreateInstance(Type type, Boolean nonPublic) +83 System.Activator.CreateInstance(Type type) +6 System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +55 [InvalidOperationException: An error occurred when trying to create a controller of type 'NinjectTest.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.] System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +179 System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController&amp; controller, IControllerFactory&amp; factory) +197 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155 </code></pre> <p>When I checked to see what the <code>DependencyResolver</code> was I saw this:</p> <p><img src="https://i.stack.imgur.com/NqENI.jpg" alt="enter image description here"></p> <p>When I do the same with a VS 2013 Express instance and create a fresh MVC 4 empty web application I see that the <code>DependencyResolver</code> is the Ninject one.</p> <p>I do have a runnable VS 2010 solution but all external file storage sites are blocked at my workplace so I will link it latter, if anyone has any thoughts in the meantime....</p> <p>My solution in the meantime is to wire up the resolver manually but I shouldn't have to do this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload