Ninject 尚未为 Web 应用程序注册内核
Ninject no kernel has been registered for the web application
我刚刚继承了一个用 Framework 4.8 编写的程序。这是一个 asp.net 应用程序。当我们尝试点击我们网站上的登录页面时,我们收到此错误:
Event code: 3005 Event message: An unhandled exception has occurred. Event time: 2/26/2021 11:35:59 AM Event time (UTC):
2/26/2021 6:35:59 PM Event ID: a930ec5b24ce461cb7ea325a5a3df94d
Event sequence: 10 Event occurrence: 5 Event detail code: 0
Application information:
Application domain: /LM/W3SVC/2/ROOT/ControlRoom-1-132588368625020589
Trust level: Full
Application Virtual Path: /ControlRoom
Application Path: [path to app]
Machine name: 945597-PREVIDEN Process information:
Process ID: 2680
Process name: w3wp.exe
Account name: IIS APPPOOL\login.controlroom Exception information:
Exception type: InvalidOperationException
Exception message: The type ASP.usercontrols_usernamepasswordlogin_ascx requested an injection,
but no kernel has been registered for the web application. Please
ensure that your project defines a NinjectHttpApplication. at
Ninject.Web.KernelContainer.Inject(Object instance) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Control.InitRecursive(Control namingContainer) at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: [url]Login.aspx?ReturnUrl=/controlroom
Request path: /ControlRoom/Login.aspx
User host address: [host IP]
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\login.controlroom Thread information:
Thread ID: 62
Thread account name: IIS APPPOOL\login.controlroom
Is impersonating: False
Stack trace: at Ninject.Web.KernelContainer.Inject(Object instance) at System.Web.UI.Control.InitRecursive(Control
命名容器)在 System.Web.UI.Control.InitRecursive(控制
namingContainer) 在 System.Web.UI.Control.InitRecursive(控制
namingContainer) 在 System.Web.UI.Control.InitRecursive(控制
namingContainer) 在 System.Web.UI.Control.InitRecursive(控制
namingContainer) 在 System.Web.UI.Control.InitRecursive(控制
namingContainer)在 System.Web.UI.Page.ProcessRequestMain(布尔值
includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)
我已经尝试重置应用程序池、重新部署站点,甚至重新启动整个服务器,但它仍然失败。我没有使用 Ninject 的经验,我对问题或解决方案一无所知。托管此页面的主站点正在运行,只是此页面出现故障。如果需要,我可以提供代码,但我不知道此时有什么用。该站点正在使用 Ninject 3.2.0
这实际上是 web.config 文件中的连接字符串的问题。一旦我们将它指向正确的位置,它就会再次开始工作。它与 Ninject 无关,那是错误被捕获和抛出的地方,这反过来又使我们摆脱了实际问题。
我刚刚继承了一个用 Framework 4.8 编写的程序。这是一个 asp.net 应用程序。当我们尝试点击我们网站上的登录页面时,我们收到此错误:
Event code: 3005 Event message: An unhandled exception has occurred. Event time: 2/26/2021 11:35:59 AM Event time (UTC): 2/26/2021 6:35:59 PM Event ID: a930ec5b24ce461cb7ea325a5a3df94d Event sequence: 10 Event occurrence: 5 Event detail code: 0
Application information: Application domain: /LM/W3SVC/2/ROOT/ControlRoom-1-132588368625020589 Trust level: Full Application Virtual Path: /ControlRoom Application Path: [path to app] Machine name: 945597-PREVIDEN Process information: Process ID: 2680 Process name: w3wp.exe Account name: IIS APPPOOL\login.controlroom Exception information: Exception type: InvalidOperationException Exception message: The type ASP.usercontrols_usernamepasswordlogin_ascx requested an injection, but no kernel has been registered for the web application. Please ensure that your project defines a NinjectHttpApplication. at Ninject.Web.KernelContainer.Inject(Object instance) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)Request information: Request URL: [url]Login.aspx?ReturnUrl=/controlroom Request path: /ControlRoom/Login.aspx User host address: [host IP] User: Is authenticated: False Authentication Type: Thread account name: IIS APPPOOL\login.controlroom Thread information: Thread ID: 62 Thread account name: IIS APPPOOL\login.controlroom Is impersonating: False Stack trace: at Ninject.Web.KernelContainer.Inject(Object instance) at System.Web.UI.Control.InitRecursive(Control
命名容器)在 System.Web.UI.Control.InitRecursive(控制 namingContainer) 在 System.Web.UI.Control.InitRecursive(控制 namingContainer) 在 System.Web.UI.Control.InitRecursive(控制 namingContainer) 在 System.Web.UI.Control.InitRecursive(控制 namingContainer) 在 System.Web.UI.Control.InitRecursive(控制 namingContainer)在 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)
我已经尝试重置应用程序池、重新部署站点,甚至重新启动整个服务器,但它仍然失败。我没有使用 Ninject 的经验,我对问题或解决方案一无所知。托管此页面的主站点正在运行,只是此页面出现故障。如果需要,我可以提供代码,但我不知道此时有什么用。该站点正在使用 Ninject 3.2.0
这实际上是 web.config 文件中的连接字符串的问题。一旦我们将它指向正确的位置,它就会再次开始工作。它与 Ninject 无关,那是错误被捕获和抛出的地方,这反过来又使我们摆脱了实际问题。