gpt4 book ai didi

c# - CaSTLe Windsor 从 2.5 升级到 3.3 (ASP.Net MVC)

转载 作者:行者123 更新时间:2023-12-02 04:27:28 25 4
gpt4 key购买 nike

我正在升级 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>

当我运行我的网络应用程序时,我立即得到运行时错误页面,没有任何异常......并且在检查事件日志后我发现了这一点,

Exception information: Exception type: ConfigurationErrorsException Exception message: Could not load type 'Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule' from assembly 'Castle.Windsor'. at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) at System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement)
at System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) at System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) at System.Web.HttpApplication.GetModuleCollection(IntPtr appContext)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) Could not load type 'Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule' from assembly 'Castle.Windsor'. at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)

无法找到任何解决方案......

最佳答案

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

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

关于c# - CaSTLe Windsor 从 2.5 升级到 3.3 (ASP.Net MVC),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25884457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com