Looks like you forgot to register the http module with Windsor Castle with IIS7

随声附和 提交于 2019-11-29 00:37:46

问题


I am using windsor DI framework in one of my MVC project. The project works fine when I tried to run from Visual Studio 2008.

But when i tried to run the project creating an application in IIS7 then I recieved the following error message:

Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule Add '<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" />' to the section on your web.config

But this module already exists in the httpmodule section of web.config file.

Does anyone know what I have to do to eliminate this problem.


回答1:


Try adding it to the system.webServer section as well?

<configuration>
    <system.web>
        <httpModules>
            <add name="PerRequestLifestyle" type="..." />
        </httpModules>
    </system.web>
    <system.webServer>
        <modules>
            <add name="PerRequestLifestyle" type="..." />
        </modules>
    </system.webServer>
</configuration>



回答2:


I had the same error, but it caused by another reason:

I tried to resolve IService at Application_Start for custom route class processing, but type for IService was registered with PerWebRequestLifestyle. Routing subsystem stays at higher level that web request, and objects not exist at route processing time.




回答3:


It helped me:

<system.web>
  <httpModules>
      <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
  </httpModules>
</system.web>



回答4:


I've come across this issue in my dev enviroment. What's worth noting is this tag:

  <validation validateIntegratedModeConfiguration="false"/>

While it obviously does what it says on the tin, it can stop those pesky errors showing up. Assuming the rest of your configuration is working Ok.

What has worked for me:

<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <modules runAllManagedModulesForAllRequests="true">
    <remove name="PerRequestLifestyle"/>
    <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor"/>
  </modules>
</system.webServer>



回答5:


I wrote a blog post that explains the issue in a code-level by decompiling the Castle.Windsor.dll.

Fixed and Explained: Forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule



来源:https://stackoverflow.com/questions/258011/looks-like-you-forgot-to-register-the-http-module-with-windsor-castle-with-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!