Do you see that a WCF service with aspNetCompabitilityEnabled=”true” works fine on a machine with .net framework runtime 4.5, but the same service fails to activate with the below exception on a machine with v4.0 runtime. Here is how you can solve this issue:

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

Check if your service definition explicitly overriddes the default value of AspNetCompatibilityRequirements() attribute. If not explicitly annotate your service definition with [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] attribute like in v4.0.

The reason for this kind of a failure is due to defaults change of ASP.NET compatibility mode value in 4.5. When you set the aspNetCompabitilityEnabled=”true” in your web.config and without setting any compatibility setting on service
definition, then:

On machine with v4.5 runtime: Individual service definitions automatically gets RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed as the default. So your service will activate successfully.

On machine with v4.0 runtime: Individual service definitions automatically gets RequirementsMode = AspNetCompatibilityRequirementsMode.NotAllowed as the default. So your service will fail to activate with the above error.

As I mentioned before, you can solve this issue by explicitly overriding default value of AspNetCompatibilityRequirements attribute on individual service definitions to avoid v4.0 defaults to kick in.