Failed to load conflict type "System.ServiceModel.Activation.HttpHandler" with WCF REST

I am having a problem with WCF REST Service. I get:

Failed to load type 'System.ServiceModel.Activation.HttpHandler' from the assembly 'System.ServiceModel, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089'.

when running inside IIS in ASP.NET 4.0 AppPool.

The problem only occurs if:

  • Running inside IIS
  • When ASP.NET Compatibility is Enabled

Running in Cassini - it works correctly without problems. Work with ASP.NET compatibility is disabled - it works without problems.

It seems like this is some kind of handler version conflict trying to create the wrong version of the handler, which in turn is trying to load an older version of System.ServiceModel, but I could not trace this.

Has anyone seen anything like this before and have ideas on how to track this further?

I looked at ApplicationHost.config and the master web.config files for System.ServiceModel and HttpHandler links, but no luck. There.

+++ Rick ---

+8
wcf wcf-rest
source share
3 answers

run your Visual Studio 2010 command prompt or select "C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319". And run the following command at a command prompt:

aspnet_regiis.exe -iru

This will register the latest version of .net. Also make sure the latest .net version is running in your application pool

+11
source

So, as expected, this turned out to be a version conflict in the default handler mappings in ApplicationHost.config. In particular, IIS has mappings for ASP.NET 2.0 and specific ASP.NET 4.0 links for the service activation processor (and module), and 2.0 links were not limited to the pre-confidential version.

To fix this problem, I had to change (in the root of the system in ApplicationHost.config):

<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" /> 

in

 <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode,runtimeVersionv2.0" /> 

Pay attention to EXPLICIT runtimeVersion2.0. There are additional * .svc cards in the same section for runtimeVersion4.0, which then run at appropriate intervals.

According to Microsoft, this situation can occur when some old tools are installed (am I guessing Azure tools?) That do not register the execution version properly.

The problem is resolved.

+8
source

There is another way if all of the above does not work. (Strange)

We used Windows Server 2008 R2 SP1 with IIS 7.5.7600

After registering the last structure specified in the answer above,

You need to map the add assembly handler v.4.0 manually with web.config and remove the "ServiceModel" from the modules.

  <system.webServer> <handlers> <remove name="svc-Integrated" /> <add name=".svc" verb="*" path="*.svc" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </handlers> <modules> <remove name="ServiceModel" /> </modules> </system.webServer> 

More here

+5
source

Source: https://habr.com/ru/post/650776/


All Articles