IIS8:无法加载类型“System.ServiceModel.Activation.HttpModule”

Ban*_*San 1 c# asp.net httphandler asp.net-mvc-4 iis-8

有很多问题可以回答这个问题,但没有一个答案对我有用。

最初,当我尝试PUTor DELETE (也可能是其他动词)时,我得到了 405 。看了一些问题,解决方案似乎是更改处理程序映射。

我更改了以下内容:

ExtensionlessUrlHandler-ISAPI-4.0_32bit
ExtensionlessUrlHandler-ISAPI-4.0_64bit
WebDAV
Run Code Online (Sandbox Code Playgroud)

我注意到动词已经在One of the following verbs盒子里了,所以无奈之下我把它改成接受所有动词。

现在,我什至无法加载网页,更不用说发出任何像 一样奇特的请求DELETE,我立即得到一个黄屏死机:

Server Error in '/' Application.

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153
   System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +100
   System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +124
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76

[ConfigurationErrorsException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12687536
   System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
   System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +66
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +300
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722297

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18045
Run Code Online (Sandbox Code Playgroud)

到目前为止,我有:

  1. 检查 ASP.NET 4.5 是通过 Web PI 安装的
  2. 跑步 dism /online /enable-feature /featurename:IIS-ASPNET45
  3. 跑步 "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
  4. 跑步 C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -I
  5. iisreset比我能做的更多
  6. 替换ServiceModel中的applicationHost.config

    <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />

替换为:

<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv4.0" />
Run Code Online (Sandbox Code Playgroud)

我还能做什么,或者我应该去哪里找?

谢谢

戴夫

小智 5

您还必须使用 dism /online /enable-Feature /all /FeatureName:WCF-HTTP-Activation45 激活 servicemodel 4.0

并在 IIS 管理器(服务器 -> 功能 -> 模块)中检查是否看到 servicemodel 4.0,然后删除 servicemodel。