Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load type 'System.ServiceModel.Activation.HttpModule'

Tags:

asp.net

iis

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

like image 415
user2110292 Avatar asked Mar 04 '13 10:03

user2110292


4 Answers

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

like image 116
scubaFun Avatar answered Nov 20 '22 05:11

scubaFun


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

like image 40
Matt Avatar answered Nov 20 '22 04:11

Matt


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

like image 2
Kokulan Eswaranathan Avatar answered Nov 20 '22 04:11

Kokulan Eswaranathan


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" />
like image 2
Oday Hazeem Avatar answered Nov 20 '22 04:11

Oday Hazeem