Featured Post

TechEd Day 2

It is day two of TechEd and my feet and legs are killing me.  My feet didn’t get a chance to rest after the four day whirlwind tour of Disney World.  I told my wife that I was going to have to go to TechEd just so I could rest   Here is day two’s activities. Biztalk WCF Adapter The first...

Read More

WCF Service Cannot Be Activated Because of ASP.NET Compatibility

Posted by Keith Elder | Posted in WCF | Posted on 08-03-2010

3

I just created a brand new solution in Visual Studio 2010 Release Candidate playing around with some new ideas on WCF Data Services. I launched the solution to test my service and I was greeted with this lovely error:

The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as ‘Allowed’ or ‘Required’.

This is a pretty easy fix but I thought I’d blog it anyway.  There are two options as the error points out.  Add an attribute or change the config file.  Here’s what you need to add if you want to go the attribute route:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

If you want to go the web.config route instead then change the serviceHostingEnvironment element as follows.

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />

Hope this helps.