[RESOLVED]The static container already has a kernel associated with it!

Server Error in ‘/’ Application.


The static container already has a kernel associated with it!

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.NotSupportedException: The static container already has a kernel associated with it!

Source Error: 

Line 25:             DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
Line 26:             DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
Line 27:             bootstrapper.Initialize(CreateKernel);
Line 28:         }
Line 29:         


Source File: d:ProjectsAstechSystemsSportBettingSystemWorkspace.0.1SportBettingSystemSportBettingSystem.WebClientAppStartNinjectWebCommon.cs    Line: 27 

Stack Trace: 

[NotSupportedException: The static container already has a kernel associated with it!]
   Ninject.Web.KernelContainer.set_Kernel(IKernel value) +68
   Ninject.Web.NinjectWebHttpApplicationPlugin.Start() +8
   Ninject.Web.Common.Bootstrapper.<Initialize>b__0(INinjectHttpApplicationPlugin c) +8
   Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable`1 series, Action`1 action) +130
   Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) +140
   SportBettingSystem.WebClient.NinjectWebCommon.Start() in d:ProjectsAstechSystemsSportBettingSystemWorkspace.0.1SportBettingSystemSportBettingSystem.WebClientAppStartNinjectWebCommon.cs:27

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +57
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +350
   WebActivatorEx.ActivationManager.Run() +78

[InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

 I
got this error after renaming the project path, and location (modifying the project file). i have tried to remove NInject and reinstall it but the same error appeared!

i
don’t know  what happening!  any idea will be helpfull


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34212

Hi  Astechnology,

Thanks for your post.

According to your description,

Astechnology

 I got this error after renaming the project path, and location (modifying the project file). i have tried to remove NInject and reinstall it but the same error appeared!

Please you can try to restart  the Visual Studio

and

Astechnology

The static container already has a kernel associated with it!

There’s a similar thread:

Ninject MVC3 – bootstrapper throwing “Already Initialized” exception

More information:

http://twentytech.net/dotnetnuke/ninject-dependency-injection-dnn/

Hope this can be helpful.

Best Regards,

Eileen

Leave a Reply