开发者

Could not load type 'System.ServiceModel.Activation.HttpHandler' Version conflict with WCF REST

I've run into a pro开发者_开发问答blem with WCF REST Service. I get:

Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

when running inside of the IIS in an ASP.NET 4.0 AppPool.

The problem seems to occur only if:

  • Running inside of IIS
  • When ASP.NET Comaptibility is enabled

Running in Cassini - no problem it works properly. Running with ASP.NET compatibility off - no problem it works.

It appears that it's some sort of handler version conflict trying to instantiate the wrong version of the handler that in turn tries to load an older version of System.ServiceModel, but I haven't been able to trace this down.

Anybody seen anything like this before and have any ideas how to track this down further?

I've looked in ApplicationHost.config and the master web.config files for System.ServiceModel and HttpHandler references but no luck. There.

+++ Rick ---


fire up your Visual Studio 2010 Command Prompt or browse to "C:\Windows\Microsoft.NET\Framework\ v4.0.30319". And run the following command from the command prompt:

aspnet_regiis.exe -iru

This will register latest .net version. Also make sure your app pool is running latest version of .net


So as expected this turned out to be a versioning conflict in the default handler mappings in ApplicationHost.config. Specifically IIS has mappings for ASP.NET 2.0 and ASP.NET 4.0 specific references to the service activation handler (and module) and the 2.0 references weren't restricted by a version specific preCondition.

To fix the above problem I had to change (at the System root 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" />

to:

<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" />

Note the EXPLICIT runtimeVersion2.0. There are additional *.svc maps in the same section for the runtimeVersion4.0 which then fire the appropriate runtimes.

According to Microsoft this situation can arise when some older tools (I'm guessing Azure tools???) are installed that don't register the runtime version properly.

Problem solved.


There is one more way if all of above doesn't work. (Strange)

We were using Windows Server 2008 R2 SP1 with IIS 7.5.7600

After registering latest framework as given in above answer,

You need to the add handler mapping to v.4.0 assembly manually to web.config and remove "ServiceModel" from 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜