Note that there are some explanatory texts on larger screens.

plurals
  1. PONinject MVC3 - bootstrapper throwing "Already Initialized" exception
    primarykey
    data
    text
    <p>I've created an empty Asp.Net MVC3 project, and used nuget <code>install-package Ninject.MVC3</code></p> <p>Without doing anything else (no services registered and not even a controller created) I run the application.</p> <p>The Project breaks on line 22 in NinjectMVC3.cs with the following exception:</p> <blockquote> <p>[InvalidOperationException: Already Initialized!] Ninject.Web.Mvc.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Maintenance2.2\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\Bootstrapper.cs> :58 Mvc.App_Start.NinjectMVC3.Start() in c:\Projects\Events\Events\App_Start\NinjectMVC3.cs:22</p> <p>[TargetInvocationException: Exception has been thrown by the target of an invocation.]<br> System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct&amp; sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0<br> System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +72<br> System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +335<br> System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28<br> System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19<br> WebActivator.BaseActivationMethodAttribute.InvokeMethod() +199 WebActivator.ActivationManager.RunActivationMethods() +330 WebActivator.ActivationManager.RunPreStartMethods() +27 WebActivator.ActivationManager.Run() +39</p> </blockquote> <p>The line in NinjectMVC3.cs is:</p> <pre><code>public static void Start() { DynamicModuleUtility.RegisterModule(typeof(OnePerRequestModule)); DynamicModuleUtility.RegisterModule(typeof(HttpApplicationInitializationModule)); bootstrapper.Initialize(CreateKernel); // &lt;- this one right here... } </code></pre> <p>What is going on with this? I've used Ninject for MVC3 in other projects without problems at all. I do notice that the second line in the Start() method is not included in older (weeks) packages of Ninject.MVC3, so maybe something else has been broken in a recent update also?</p> <p>Please help!</p> <p><strong>Edit to address answer from Remo</strong></p> <p>This is from my global.asax.cs</p> <pre><code> public class MvcApplication : System.Web.HttpApplication { </code></pre> <p>The global.asax is 100% standard aswell. No adjustments done.</p> <p><strong>EDIT - Problem is gone...</strong></p> <p>I honestly have no idea what caused this, but after a few restarts of Visual Studio, and a full reboot, the project is working as it should. Neither can I recreate the problem in new projects.</p> <p>Sorry for wasting your time :)</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