温莎城堡从2.5升级到3.3(ASP.NetMVC)

本文关键字:ASP NetMVC 城堡 5升 | 更新日期: 2023-09-27 18:22:05

我正在升级NHibernate,Castle.Core,Castle.Windsor(从2.5升级到3.3)

IIS版本:7.5

我在web.config 中有这个

<configuration>
<system.web>
    <httpModules>
          <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
    </httpModules>
</system.web>
<system.webServer>
     <modules runAllManagedModulesForAllRequests="true">
          <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor"/> 
    </modules>
</system.webServer>
</configuration>

当我运行我的web应用程序时,我会立即得到运行时错误页面,没有任何异常。。在检查了事件日志后,我发现了这个,

异常信息:异常类型:ConfigurationErrorsException异常消息:无法从加载类型"Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule"温莎城堡集会System.Web.Configuration.ConfigUtil.GetType(字符串类型名称,字符串propertyName,ConfigurationElement configElement,XmlNode节点,布尔检查AptcaBit,布尔ignoreCase)System.Web.Configuration.ConfigUtil.GetType(字符串类型名称,字符串propertyName,ConfigurationElement configElement,布尔值checkAptcaBit)System.Web.Configuration.Common.ModulesEntry.SecureGetType(字符串typeName,String propertyName,ConfigurationElement configElement)
位于System.Web.Configuration.Common.ModulesEntry.ctor(字符串名称,字符串类型名称,字符串属性名称,配置元素configElement)System.Web.HttpApplication.BuildIntegratedModuleCollection(列表`1moduleList)System.Web.HttpApplication.GetModuleCollection(IntPtr appContext)
位于System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtrappContext、HttpContext上下文、MethodInfo[]处理程序)System.Web.HttpApplication.InitSpecial(HttpApplicationState状态,MethodInfo[]处理程序、IntPtr appContext、HttpContext上下文)System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtrappContext、HttpContext上下文)System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtrappContext)无法加载类型来自的"Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule"温莎城堡集会System.RuntimeTypeHandle.GetTypeByName(字符串名称,布尔值throwOnError,布尔ignoreCase,仅布尔反射,StackCrawlMarkHandle堆栈标记,IntPtr pPrivHostBinder,布尔loadTypeFromPartialName,ObjectHandleOnStack类型)System.RuntimeTypeHandle.GetTypeByName(字符串名称,布尔值throwOnError,布尔ignoreCase,仅布尔反射,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔值loadTypeFromPartialName)在System.RuntimeType.GetType(字符串typeName,布尔throwOnError,布尔ignoreCase,布尔reflectionOnly,StackCrawlMark&stackMark)System.Type.GetType(字符串类型名称,布尔throwOnError,布尔ignoreCase)在System.Web.Compilation.BuildManager.GetType(字符串typeName,Boolean throwOnError,Boolean ignoreCase)System.Web.Configuration.ConfigUtil.GetType(字符串类型名称,字符串propertyName,ConfigurationElement configElement,XmlNode节点,布尔校验AptcaBit,布尔ignoreCase)

找不到任何解决方案。。。。

温莎城堡从2.5升级到3.3(ASP.NetMVC)

首先,不需要在IIS 7.5中声明<httpModules>,在<system.webServer>中定义<modules>标记就足够了。第二;无法加载类型"与不正确的类型、dll甚至命名空间有关。我认为;PerWebRequestLifestyleModule";类已移动到新程序集,因此您只需要更新nuget包即可添加Castle.Facilities.AspNet.SystemWeb并替换下面的代码。

<modules runAllManagedModulesForAllRequests="true">
    <add name="PerRequestLifestyle" type="Castle.Facilities.AspNet.SystemWeb.PerWebRequestLifestyleModule, Castle.Facilities.AspNet.SystemWeb" />
</modules>