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

前端 未结 5 433
旧巷少年郎
旧巷少年郎 2020-12-28 14:36

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 cre

相关标签:
5条回答
  • 2020-12-28 15:00

    It helped me:

    <system.web>
      <httpModules>
          <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
      </httpModules>
    </system.web>
    
    0 讨论(0)
  • 2020-12-28 15:03

    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.

    0 讨论(0)
  • 2020-12-28 15:03

    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>
    
    0 讨论(0)
  • 2020-12-28 15:04

    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

    0 讨论(0)
  • 2020-12-28 15:08

    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>
    
    0 讨论(0)
提交回复
热议问题