You have reached the blog of Keith Elder. Thank you for visiting! Feel free to click the twitter icon to the right and follow me on twitter.

WCF Service Cannot Be Activated Because of ASP.NET Compatibility

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

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.

Comments (3)

What if I don’t want to do aspNetCompatibilityEnabled=”false” in the config file ?

Thanks! Got me going.

Thanks. Your opinion solved my problem!

Write a comment