title: IIS8: Could not load type 'System.ServiceModel.Activation.HttpModule'
body: <p>There are lots of questions answering this, but none of the answers are working for me.</p>
  
  <p>Originally, I was getting a 405 when I was trying to <code>PUT</code> or <code>DELETE</code>  (probably other verbs too).  Looking at some questions, the solution seemed to be to change the Handler Mappings.</p>
  
  <p>I changed the following:</p>
  
  <pre><code>ExtensionlessUrlHandler-ISAPI-4.0_32bit
  ExtensionlessUrlHandler-ISAPI-4.0_64bit
  WebDAV
  </code></pre>
  
  <p>I noticed that the verbs were already in the <code>One of the following verbs</code> box, so in desperation I changed it to accept all verbs.</p>
  
  <p>Now, I can't even load the webpage, let alone make any exotic requests like a <code>DELETE</code>, I immediately get a yellow screen of death:</p>
  
  <pre><code>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&amp; 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
  </code></pre>
  
  <p>So far I have:</p>
  
  <ol>
  <li>Checked ASP.NET 4.5 is installed via Web PI</li>
  <li>Running <code>dism /online /enable-feature /featurename:IIS-ASPNET45</code></li>
  <li>Running <code>"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r</code></li>
  <li>Running <code>C:\Windows\Microsoft.NET\Framework64\v4.0.30319&gt;aspnet_regiis -I</code></li>
  <li>More <code>iisreset</code>s than I can could</li>
  <li><p>Replacing the <code>ServiceModel</code> in the <code>applicationHost.config</code>:</p>
  
  <p><code>&lt;add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" /&gt;</code></p></li>
  </ol>
  
  <p>replaced with:</p>
  
  <pre><code>&lt;add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler,runtimeVersionv4.0" /&gt;
  </code></pre>
  
  <p>What else can I do, or where should I be looking?</p>
  
  <p>Thanks</p>
  
  <p>Dave</p>