Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 静态容器已经有一个与之关联的内核_Asp.net_Azure_Webforms_Ninject - Fatal编程技术网

Asp.net 静态容器已经有一个与之关联的内核

Asp.net 静态容器已经有一个与之关联的内核,asp.net,azure,webforms,ninject,Asp.net,Azure,Webforms,Ninject,我在部署到Azure时遇到与Ninject相关的错误: 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 execut

我在部署到Azure时遇到与Ninject相关的错误:

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: 

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: 


[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
   AlamomiAdmin.App_Start.NinjectWebCommon.Start() in c:\a\src\AlamomiUniverse\AlamomiAdmin\App_Start\NinjectWebCommon.cs:26

[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) +9930568
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
但它在当地很管用。而且它以前一直在本地和Azure上工作,我不记得最近发生了什么变化(例如,我没有得到更新版本的Ninject)。我查看了相关帖子,但仍然无法解决我的问题

以下是部署到Azure后的错误页面:

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: 

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: 


[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
   AlamomiAdmin.App_Start.NinjectWebCommon.Start() in c:\a\src\AlamomiUniverse\AlamomiAdmin\App_Start\NinjectWebCommon.cs:26

[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) +9930568
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
“/”应用程序中出现服务器错误。 静态容器已经有一个与之关联的内核! 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源。 异常详细信息:System.NotSupportedException:静态容器已具有与其关联的内核! 源错误: 在执行当前web请求期间生成了未经处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来识别。 堆栈跟踪: [NotSupportedException:静态容器已具有与其关联的内核!] Ninject.Web.KernelContainer.set_Kernel(IKernel值)+68 Ninject.Web.NinjectWebHttpApplicationPlugin.Start()+8 Ninject.Web.Common.Bootstrapper.b_u0(InInjectHttpApplication插件c)+8 Ninject.Infrastructure.Language.ExtensionsforIEnumerableSoft.Map(IEnumerable`1系列,Action`1 Action)+130 Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback)+140 c:\a\src\AlamomiUniverse\AlamomiAdmin\App\u Start.NinjectWebCommon.Start()中的AlamomiAdmin.App\u Start.NinjectWebCommon.Start() [TargetInvocationException:调用的目标已引发异常。] System.RuntimeMethodHandle.InvokeMethod(对象目标、对象[]参数、签名符号、布尔构造函数)+0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象obj,对象[]参数,对象[]参数)+192 System.Reflection.RuntimeMethodInfo.Invoke(对象obj,BindingFlags invokeAttr,绑定器绑定器,对象[]参数,CultureInfo区域性)+155 WebActivateX.BaseActivationMethodAttribute.InvokeMethod()+57 WebActivateX.ActivationManager.RunActivationMethods(布尔设计模式)+350 WebActivatorEx.ActivationManager.Run()+78 [InvalidOperationException:在WebActivatorEx.ActivationManager类型上运行的应用程序启动前初始化方法引发异常,并显示以下错误消息:调用目标已引发异常..] System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1方法,Func`1设置主机环境文化)+547 System.Web.Compilation.BuildManager.InvokePrestartinethods(ICollection`1方法)+132 System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串preStartInitListPath,布尔值&isRefAssemblyLoaded)+102 System.Web.Compilation.BuildManager.ExecuteRepapStart()+153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager、IAApplicationHost appHost appHost、IConfigMapPathFactory configMapPathFactory、HostingEnvironmentParameters hostingParameters、PolicyLevel PolicyLevel、Exception appDomainCreationException)+521 [HttpException(0x80004005):在WebActivatex.ActivationManager类型上运行的应用程序启动前初始化方法引发了异常,并显示以下错误消息:异常已由调用的目标引发..] System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+9930568 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文)+254
我已经为此沮丧了一周。今天我找到了解决办法。我想一定有两个重复的Ninject.dll/Ninject.Web.dll或Azure中Ninject的任何dll文件。因此,我必须在部署之前删除Azure中的所有现有文件。我从VisualStudio部署

这就是我所做的。在Visual Studio中,右键单击项目,然后选择“发布…”。在弹出窗口中的“设置”下,选中名为“在目标位置删除其他文件”的复选框。再次部署

现在它成功了