Jig*_*eth 2 c# asp.net-mvc castle-windsor
我正在升级 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>
Run Code Online (Sandbox Code Playgroud)
当我运行我的 Web 应用程序时,我会立即获得运行时错误页面,没有任何异常......并且在检查事件日志后我发现了这一点,
异常信息:异常类型:ConfigurationErrorsException 异常消息:无法从程序集“Castle.Windsor”加载类型“Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule”。在 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode 节点, Boolean checkAptcaBit, Boolean ignoreCase) 在 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) 在 System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement)
在 System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) 在 System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) 在 System.Web.HttpApplication.GetModuleCollection(IntPtr)应用上下文)
在 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) 在 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) 在 System.Web.HttpApplicationFactory。 GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) 无法从程序集“Castle.Windsor”加载类型“Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule”。在 System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, BooleanreflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName,
无法为此找到任何解决方案......
首先,<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
596 次 |
| 最近记录: |