15
votes

I am run aspnet_regiis.exe, still I am getting same error:

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′.

8
Can you provide info about .net / asp.net and iis versions?Stefano Altieri

8 Answers

21
votes

If you are running Windows 8, this method will not work. Microsoft will not let you to run this command, telling you this:

This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool.

The reasons for this are on this link: http://support.microsoft.com/kb/2736284 .

The solution that worked for me is posted on this link, on the answer by Neha: System.ServiceModel.Activation.HttpModule error

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

15
votes

I got the same error after upgrading the IIS server to .NET 4.5.1 (previously .NET 4.0 was installed). In my case, running aspnet_regiis with the parameter -iru fixed the problem, ie.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -iru

Note: on a 64bit system you should use

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -iru

Notes:

  • .NET 4.0 and higher (e.g. 4.5.1) all installs into v.4.0.30319, this has changed compared to earlier versions (you will not find a v4.5 folder). To get the installed .NET framework versions, see this answer.

  • The cause of this error is described here, If you want to check manually, I cite the following from this article:

This issue occurs because the Applicationhost.config file for Windows Process Activation Service (WAS) has the following section defined, and this section is incompatible with the .NET Framework 4.0:

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

This section should be defined as follows (notice the preCondition):

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

Note: You can find the Applicationhost.config file in the following location: %windir%\system32\inetsrv\config

2
votes

It seems like the ASP.NET 4.0 is not properly registered with IIS. Could you please try re-registering asp.net with IIS ? You could try for both 2.0 and 4.0 just to make sure it is done for all the .NET versions.

Use the following commands for both version of asp.net to register asp.net with IIS

aspnet_regiis -i

This is located in both .NET framework version folders.

C:\Windows\Microsoft.NET\Framework\v4.0.30319 and C:\Windows\Microsoft.NET\Framework\v2.0.50727

1
votes

Get to the applicationhost.config file in the following directory: C:\Windows\system32\inetsrv\config

The following section will be defined:

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

The above definition is incompatible with the .NET framework 4.0, you can get this issue resolved by replacing the above section by the following:

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

To resolve this issue, run the following command line:

  • aspnet_regiis.exe /iru The Aspnet_regiis.exe file can be found in one of the following locations: %windir%\Microsoft.NET\Framework\v4.0.30319 %windir%\Microsoft.NET\Framework64\v4.0.30319 (on a 64-bit computer)
0
votes

To resolve this issue, run the following command line:

  1. Close the Application
  2. in the project file(Web Application) change the virtual directory
  3. Now OPEN the Project file

It will work definitely.

0
votes

On Windows 2012, the following worked :

For a reason I don't know the default application pool was set up to use 4.0 :

Application Pool Properties

but it was not correctly reflected in c:\windows\system32\inetesrv\config\applicationhost.config :

<add name="DefaultAppPool" enable32BitAppOnWin64="true" />

I had to set it back to 2.0 and then to 4.0 again, and then the config file was fine and the error disapeared :

<add name="DefaultAppPool" enable32BitAppOnWin64="true" managedRuntimeVersion="v4.0" />
0
votes

I am late, hope it will help someone ....This is a known issue with IIS 8.0

The solution is to delete the 3.x module and handler from IIS manager. You could delete them at the application or site level if you want to keep them in applicationHost.config. But I wanted to delete them from applicationHost.config. do the following steps:

In IIS manager, click the machine name node. In “Features View”, double-click “Modules”. Find “ServiceModel” and remove it. Image 1 for Solve IIS 8 Error: Could not load type ‘System.ServiceModel.Activation.HttpModule’

Go back to the machine name node’s “Features View”, double-click “Handler Mappings”. Find “svc-Integrated” and remove it. Image 2 for Solve IIS 8 Error: Could not load type ‘System.ServiceModel.Activation.HttpModule’