7

what is the cause of this error on below line?

<system.web>
    <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="fa-IR" uiCulture="fa-IR" />
    <compilation targetFramework="4.0" debug="true">
      <assemblies> <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral,  PublicKeyToken=b77a5c561934e089" />
Negar
  • 866
  • 2
  • 10
  • 20
  • 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' – Negar Dec 07 '10 at 08:28

7 Answers7

33

Everywhere the problem to this solution was mentioned as re-registering aspNet by using aspnet_regiis.exe. But this did not work for me.

Though this is a valid solution (as explained beautifully here)

but it did not work with Windows 8.

For Windows 8 you need to Windows features and enable everything under ".Net Framework 3.5" and ".Net Framework 4.5 Advanced Services".

Thanks Neha

Neha
  • 331
  • 3
  • 2
22

This happens when you install .Net 4 before enabling IIS, or if you register WCF after registering .Net 4. In either case, your App Pools will be running .Net 2.0 (which is the CLR version required for .Net 3 if you have registered WCF, which installs ASP.Net 3.5, or the default if you have installed IIS after .Net 4)).

There are many references to this on the web, e.g. the MSDN blogs: http://blogs.msdn.com/b/webtopics/archive/2010/04/28/system-typeloadexception-for-system-servicemodel-activation-httpmodule-in-asp-net-4.aspx

The fix is to re-register ASP.Net 4 from the correct (32 or 64 bit) Framework folder (Framework64 on a 64bit server), using the aspnet_regiis.exe tool, e.g.

aspnet_regiis.exe -iru

Ed209
  • 336
  • 3
  • 4
  • We tried this, and are still getting the same error, "Failed to find the RegisterModule entrypoint in the module DLL C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.ServiceModel.Activation.dll." – Bryan Aug 31 '15 at 14:53
8

For Windows 8 you need to Windows features and enable everything under .Net Framework 3.5 and .Net Framework 4.5 Advanced Services -> Enable Everything

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
Innovation Wang
  • 199
  • 1
  • 2
  • 6
2

For windows 8 the above configuration in Control panel->programs->windows features on/off enable every thing under".net Framework3.5" and ".net Framework 4.5 advanced Services" Working fine for me.

Thanks Madhavi.B

2

I had this problem on a server managed by one of our clients. I didn't have the access to run the aspnet_regiis.exe tool. As a workaround I did the following:

  1. I removed aspNetCompatibilityEnabled="true" from the <serviceHostingEnvironment> tag in the web.config
  2. removed [AspNetCompatibilityRequirements] from the webservice.cs file

Unfortunately this means that for example HttpContext.Current becomes null, I could fix my webservice by rewriting all my HttpContext.Current.Server.MapPath calls to System.Web.Hosting.HostingEnvironment.MapPath

Hope this helps someone.

RuudvK
  • 635
  • 5
  • 9
0

This problem surfaced for us immediately after we installed the Windows Management Framework 3.0/PowerShell 3.0 sp1 (KB2506143) on a Windows Server 2008 R2 x64. Windows Update then also installed KB2736422, KB2756921, and KB2656411 immediately after.

Our solution was to first uninstall KB2506143 (and the three updates that accompanied that), then run aspnet_regiis.exe -iru as suggested in Ed209's response above. Both steps were necessary to resolve the problem. Thank you, Ed209.

0
appcmd.exe set config -section:system.webServer/modules /[name='ServiceModel'].preCondition:"managedHandler,runtimeVersionv2.0" /commit:apphost

worked for me

Pecan
  • 350
  • 3
  • 14