【发布时间】:2014-11-11 03:05:39
【问题描述】:
我正在升级 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 异常消息:无法从 装配“城堡。温莎”。在 System.Web.Configuration.ConfigUtil.GetType(字符串类型名,字符串 propertyName、ConfigurationElement configElement、XmlNode 节点、 Boolean checkAptcaBit, Boolean ignoreCase) 在 System.Web.Configuration.ConfigUtil.GetType(字符串类型名,字符串 propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) 在 System.Web.Configuration.Common.ModulesEntry.SecureGetType(字符串 typeName, String propertyName, ConfigurationElement configElement)
在 System.Web.Configuration.Common.ModulesEntry..ctor(字符串名称, 字符串类型名称、字符串属性名称、配置元素 configElement)在 System.Web.HttpApplication.BuildIntegratedModuleCollection(列表`1 模块列表)在 System.Web.HttpApplication.GetModuleCollection(IntPtr appContext)
在 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext、HttpContext 上下文、MethodInfo[] 处理程序)在 System.Web.HttpApplication.InitSpecial(HttpApplicationState 状态, MethodInfo[] 处理程序,IntPtr appContext,HttpContext 上下文)在 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext,HttpContext 上下文)在 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) 无法加载类型 'Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule' 来自 装配“城堡。温莎”。在 System.RuntimeTypeHandle.GetTypeByName(字符串名称,布尔值 throwOnError, Boolean ignoreCase, Boolean reflectOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName,ObjectHandleOnStack 类型)在 System.RuntimeTypeHandle.GetTypeByName(字符串名称,布尔值 throwOnError, Boolean ignoreCase, Boolean reflectOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) 在 System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean 仅反射,StackCrawlMark 和 stackMark)在 System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) 在 System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at System.Web.Configuration.ConfigUtil.GetType(字符串类型名,字符串 propertyName、ConfigurationElement configElement、XmlNode 节点、 Boolean checkAptcaBit, Boolean ignoreCase)
找不到任何解决方案....
【问题讨论】:
-
您运行的是哪个版本的 IIS,
<modules>是configuration/system.webServer中的部分吗? -
如果您使用的是 .NET 4.0 而不是 4.5 DLL,请确保您拥有完整的框架 DLL 而不是客户端配置文件之一,因为
PerWebRequestLifestyleModule类是从客户端配置文件中编译出来的一。 -
@RussCam:更新了描述。
-
@JonathonRossi:是的,我使用的是 .NET4.0,它是完整的框架构建,而不是客户端配置文件。
-
@JigarSheth 您不需要在 IIS 7.5 中的
<httpModules>中注册它,只需在<modules>中注册。
标签: c# asp.net-mvc castle-windsor